Zombie child errors when dispatching actions with keyboard shortcuts #286
-
CodesandboxI'm trying to architect my App in a way that is performant. I'm only trying to fetch the amount of state that's required in each component to minimize re-renders. I've had runtime errors (which I thought were zombie child bugs) so I've made a sandbox to reproduce it. Runtime Error (in Cell)Uncaught TypeError: Cannot read property 'cells' of undefined
Update: Dispatching actions using the buttons work, but using keyboard shortcuts result in errors (sometimes). But I still wanted to ask whether this is the right way to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Error reproduced.
This is reproducible only when we use keyboards without using mouse for several clicks. The reason it doesn't repro with buttons is React does it internally. For reference, React-Redux exposes batch api. |
Beta Was this translation helpful? Give feedback.
This is reproducible only when we use keyboards without using mouse for several clicks.
So, what's happening is it tries to render child components before the parent, with rapid dispatch invocation.
To fix this on your end is to wrap the dispatch with
batchedUpdates
.Here's the modified one: https://codesandbox.io/s/app-tab-cell-forked-poxow
The reason it doesn't repro with buttons is React does it internally.
I don't know why we can't repro after some clicks.
For reference, React-Redux exposes batch api.