⚛️ React tip: Use a custom hook to handle array states in your components ↓
@_georgemoller118K followers
171,103 views
11 Comments
Comments from the original post on X (Twitter)

@_georgemoller
I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 50+ video animations just like this one. Check them out ↓
13 likes

@josemongedev
Do you think if you would add more methods then maybe it would be worth trying trying something like useReducer instead?
3 likes

@_georgemoller
If the logic get's more complex then yes. useState uses useReducer internally and it has a better API for a bit more complex use cases (e.g. when you need a more fine grained control over how your state changes).
2 likes

@pavl_ro
Do you think it is worth renaming the "add" function to "push"? It is doing the same thing as the "push" method of the array.
3 likes

@_georgemoller
Don't really have a strong opinion about that one, I think it's worth doing it yes to keep consistency with array helper methods.
1 like

@itswilsonhou
how do you do these animations 🤯
3 likes

@_georgemoller
I use keynote Wilson! :)
2 likes

@rohan_webdev
This is good way to handle aarays 😊🙌💯 Good explanation As always , George ✨
3 likes

@enriquemoreno
Oh, wow! I have used this pattern so many times. How did I not come up with this idea?! Thank you!
3 likes

@ak_h_il_17
Nice tip George 👍
2 likes

@_georgemoller
Thank Akhil! glad you liked it!
1 like
