Why you should avoid using state for computed properties
Hey there!
I have often seen many people (including my past self) creating state variables for any kind of value that can change across renders including the ones that can be directly dervied from existing state or props.
It wasn't until I ran into some hard to debug state synchronization bugs that I realized the downsides of this pattern.
So in this blog I try to explain why this pattern is a bad idea with an example, what should you do instead and how you can handle some edge cases when you need to dervie state from props.
Give it a read here! - Why you should avoid using state for computed properties
Also have a great weekend ahead ;) (whatever's left of it 😁).
Cheers,
Prateek
Don't miss what's next. Subscribe to Prateek's Blog: