Why Redux Store Changes Don't Re-render
HTML-код
- Опубликовано: 8 сен 2024
- When using Redux, it's common to run into issues where your store isn't updating, or isn't updating in the way you expect it to. In this edition of Bugfixes, we're tackling the most common reasons why Redux store changes don't re-render. Cheers!
--
Follow Me Online Here:
🌏 My website/blog - peterelbaum.com
✉️ My newsletter (weekly on Sundays) - peterelbaum.co...
🤓 My courses: peterelbaum.gu...
🗣 One-on-one mentoring - superpeer.com/...
🐦 Twitter: / peterelbaum
💻 GitHub: github.com/elb...
☎️ Office Hours: calendly.com/e...
--
My gear:
Main Camera: amzn.to/2Tv1WBe
Tripod: amzn.to/2t570AH
External HD: amzn.to/2t1UphI
Memory card: amzn.to/2UEQfIn
Computer mic: amzn.to/2t7mUue
--
Who am I?
I'm Peter Elbaum, a software engineer living in Raleigh, North Carolina. I make videos about code, software engineering career development, and self improvement. I also have a newsletter (peterelbaum.co...) and tweet my thoughts on money, work, and being a great dev. Feel free to get in touch!
As far as I understand it, component re-rendering will happen ONLY if either the props or the state OF THE COMPONENT change.
Changes in Redux state will not re-render the component by default even if you ensure you are changing Redux by making copies of objects in the store instead modifying the exiting objects.
That is why "connect" and "mapStateToProps" exist in Redux and the react-redux library, so that changes in the Redux state will modify a component's props and this will cause re-render.
If that's not the case, please let me know, as I am still working to fully grasp it!
That is also my understanding. You have to connect either with connect or useSelector so the local state of a component is dependent on the redux store
Thanks for sharing Peter. Another good video I’m loving the short and sweet format. Cheers
Glad you enjoyed it - thanks Bryan! :)
you should show some codes
I am using the spread operator and the issue is still persisting
yes for me as well
did you find solution?
Thank you sir I am very grateful for this video
Sure thing!
Thanks this helped me debug
Glad to hear!
This is no longer relevant with redux toolkit