-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering broken for arrays not wrapped in div #178
Comments
This is not a bug with the library, but a way react works, by default if you pass an array to react it is not going to render anything. Try changing that line to: And you'll see that it renders each pet in it's own span. |
Some general thoughts: (scroll down for the specific issue explanation) @peteyycz was party right that this is a very strange use-case that is only "accidentally" handled by React. React does not render objects but it does render arrays (because React elements are represented as arrays after compilation) and strings. As a result, it also handles arrays of strings. I don't think we would change anything in the library because of this edge case only without a strong use-case from a user as it is not really real-life like. It is tightly linked with a more practical and broad issue though which may get addressed soon. About the issue: The component correctly re-renders, just add a console.log inside the render to see it. The freshly mutated array is not reflected in the view by React though because it did not change by reference. If you replace This issue can also happen with complex multi-component third-party libraries. Check the "Passing nested data to third party components." for an explanation. In that case the third party component (or some of its children) is not re-rendered because the data it received as prop did not change as a reference. I have an idea about how to solve this but it could lead to a bunch of other problems. I will reopen the issue and keep you updated here. |
React Easy State version: x.x.x
Platform: browser / node / react-native / other
Describe the bug
If you have an array in your store and display it without wrapping it in a div it does not render or update properly.
For the toughest bugs only
https://codesandbox.io/s/pedantic-glade-ytrwo?file=/src/App.js
The text was updated successfully, but these errors were encountered: