forked from Roblox/roact-rodux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect to store before children connect to the store (Roblox#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.
- Loading branch information
1 parent
923b17b
commit ed7eb70
Showing
7 changed files
with
137 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# RoactRodux Changelog | ||
|
||
## Current master | ||
* No changes | ||
* Change order of connection to store so that Parent components are connected to the store before their children. | ||
|
||
## 1.0.0 (TODO: Date) | ||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
return { | ||
newConnectionOrder = true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
local StoreProvider = require(script.StoreProvider) | ||
local connect = require(script.connect) | ||
local getStore = require(script.getStore) | ||
local TempConfig = require(script.TempConfig) | ||
|
||
return { | ||
StoreProvider = StoreProvider, | ||
connect = connect, | ||
UNSTABLE_getStore = getStore, | ||
UNSTABLE_connect2 = connect, | ||
|
||
TEMP_CONFIG = TempConfig, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
}, | ||
|
||
"Rodux": { | ||
"$path": "modules/rodux/lib" | ||
"$path": "modules/rodux/src" | ||
}, | ||
|
||
"TestEZ": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters