Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kivircik-parantez/48f3e70dd28b63a541ed1971fd9500a1 to your computer and use it in GitHub Desktop.
Save kivircik-parantez/48f3e70dd28b63a541ed1971fd9500a1 to your computer and use it in GitHub Desktop.
Calculate Everything During Rendering
function List({ items }) {
const [isReverse, setIsReverse] = useState(false);
const [selectedId, setSelectedId] = useState(null);
// ✅ Best: Calculate everything during rendering
const selection = items.find(item => item.id === selectedId) ?? null;
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment