I struggled to understand re-rendering and memoization in React for a long time. Today I wrote the article I wish I had read many years ago. The information is concise and to the point. I hope it helps someone.
Another trick is that the setter function from useState can accept a function. This can also help save unnecessary rerenders.const [open, setOpen] = useState(false) const toggleState = useCallback(() => setOpen(!open), [open]) const