-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Parent/Child component both select Redux state, but only Parent sees changes? #4625
Comments
Don't have a specific answer for this one, I'm afraid - they ought to both update. Not sure there's anything I can do without seeing a specific example that reproduces the issue. (Also, this would really be a React-Redux question, not an RTK question.) |
I am confused why there is a |
Thanks for looking so quickly guys! I've made some progress on this and found the issue since posting, although I would still like you're input on the behavior if you don't mind :) Basically I had a bug where I was pushing directly into an array that was frozen by Immer in the Child's mapStateToProps (which I didn't include above, so you guys couldn't have known anyway). So the question is when I was doing that as the code was setup above, I got no error in the console whatsoever abour pushing into the frozen array The child just didn't re-render. However, if I selected my currentGroupId state in the Parent instead, and passed it to the child as a Prop, I suddenly got a stacktrace about the frozen array push? |
The code's kind of in flux, so there's a mix of both right now. Is that bad practice for some for some reason other than mixing styles? |
Yeah, what's happening is that the error is getting thrown in (This is yet another reason to migrate away from All that said, I am very curious how your logic ended up trying to mutate an array in |
It's just bad programming on my part I guess, and now that I know not to do that I can just fix it. Definitely vote for not swallowing errors in the framework if possible tho, this was a 1 minute fix that took like 2 days to find :( I can migrate to hooks no issue, but the docs I'd read seemed to suggest that while hooks were newer, connect was in some way better because it did some intelligent batching or something, which is why I hadn't banished it yet |
Because
Per the linked issue, it's probably fixable in some way, but making changes to
Definitely not the case, and if anything |
Good Info! Ok I'll switch to selectors, thanks for looking |
Hello,
I'm probably doing something dumb, but I've been struggling to determine what the problem is here. Essentially I have a Parent component that has a Child component, and when I select the same Redux state in both Parent and Child, only the parent sees updates? When I run and change the state, I see the Parent's "current group outer" log but not the Child's "current group inner" log?
Parent
Child
Package Json:
The text was updated successfully, but these errors were encountered: