It's 2020 and React is still the most popular frontend framework in the world. It's not just because it's relatively simpler. The fact that it ke...
For further actions, you may consider blocking this person and/or reporting abuse
So let's say I have 3 reducers (providers) and 2 UI components, I have to wrap every single component for 3 times (3 providers) if I want to use all stores in these components?
What happens if I wrap both components together? I mean is that the right way to do it? Are there any performance issues or something?
ROFL as I was writing this I actually figure out how great this is, I still wanna post this tho 😅😅, let's assume I only want to use providers 1 and 2 in comp1, I just have to move Component1 by 1 line up, there is no need to wrap it in provider3 if it won't use any features from it.
This provider actually acts like that connect function from redux right?
Great article BTW, I didn't really have time to test hooks until now, and I am glad I did now, and run into this post it was really helpful!!
Hey Mario,
Sorry for the late reply. You don't have to wrap all the components separately. Also yes there's no need to wrap the 3rd component. The provider is similar to connect function, in Redux we generally combine the reducers.
Hey Ankit,
Thanks for your response to the above question by Mario. What is the best way to wrap the without incurring performance issues? Thanks
Thanks for the article, it's great. But FYI, the word 'ciao' is in Italian, and it means both 'hello' as well as 'goodbye'. On the other hand, the word 'chau', is in Spanish, and it means only 'goodbye', which would be more appropriate in this context :)
Ah, thanks for the info mate. Today years old. Always thought ciao meant "Goodbye". Will update it.
You were almost right, in Spanish it does. Chau = Adios = Goodbye. Chau more coloquial, adios slightly more formal...both used extensively.
Thank you for the great article. Cheers.
Glad it helped. PS. For some reason "Chau" did not sound good in my head. So went with Adios :D
That was nice. Actually my question is I have tried to learn redux and found it tough as you have mentioned above. I was planning to give it one more shot. In your opinion should I completely ditch it or continue it and learn it on a fundamental level to at least have an idea.
The
useReducer
hook is actually a simpler way to understand Redux. If you understand that then you should understand Redux as well. Learning the fundamentals will help because this pattern is used a lot. Here's a good piece you can readcode-cartoons.com/a-cartoon-intro-...
Thanks
I started a global state using hooks and I came to the same solution! haha thanks for sharing, the only missing step was React.useMemo, very interesting! ❤️
Ankit, what do you think creating a npm package for this?
I think there's a package called
unstated-next
which is really good for sharing custom hooksThis article seems to be underrated, amigo :)
Thank you!
You are welcome. :D
Awesome write-up! Really well explained. Looking forward to the react-query one as well as it's also something I'm figuring out how to use!
Thank you Ankit, will be sure to try this workflow!
Thanks! This really helped 🙂
Awesome.. this post help me a lot..! thanks