You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Connect to store before children connect to the store (#31)
Connecting to the store in didMount means that child components connect to the store before their parent component. This causes them to render before their parent component which can lead to issues if the state they need depends on their props and is no longer valid due to the store changing.
The specific problem I have is that when a Player leaves, the in game playerlist has errors because the children are updated before their parent. The child component tries to access information that no longer exists in the store, but the parent will stop rendering this child when it updates due to the player leaving anyway.
I think we should be able to fix this by changing it so that connecting to the store in RoactRodux is done in init, not didMount since init is called first for parents and then for children whereas didMount is called for children first.
We could also fix this more explicitly by connecting to the store by priority (deeper in the tree = less priority). This might be a possible future fix to the problem.
I added configuration for this change by copying the GlobalConfig pattern from Roact. Let me know if I should do something a bit more lightweight than this instead.
0 commit comments