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
![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.](https://www.coodingdessign.com/wp-content/uploads/2021/12/anocBu6nhCUnoAg72EkRw54lnYVJX2jByx50-Zt1Np0.jpg)