Remove setSwapComponent method and cleanup after PR #2379#2383
Remove setSwapComponent method and cleanup after PR #2379#2383pascalbaljet merged 6 commits intomasterfrom
setSwapComponent method and cleanup after PR #2379#2383Conversation
|
@pascalbaljet it was because react was complaining about using setCurrent outside of useEffect caused by the swapComponent called at first render, so checking the variable inside fixed the problema and the setSwapComponent can be safely removed |
|
@chack1172 Thanks for clarifying! |
|
Though the tests pass, navigation is broken in the Playground with this change, so let's see if there's a solution by using
|
|
I seem to have found a solution by moving the |
|
Closing this PR as it leads to other problems. Gonna have a fresh look at it. |
|
Moved the variables back outside of the App component again, as well as the |
|
It seems working fine! |
This is a cleanup of PR #2379.
isRouterInitializedhas been renamed torouterIsInitialized.TherouterIsInitializedbool was enough to fix the problem. The additionalsetSwapComponentlogic doesn't seem to provide any benefits. Perhaps this was needed beforecurrentIsInitialPagewas introduced, but I can't reproduce it.setSwapComponenthas been removed to prevent introducing another public method on the core router. The swapping of theswapComponentmethod is now handled internally inApp.ts.swapComponentis now simply a variable that gets replaced in theuseEffecthook.manual-visits.spec.ts) but in the React implementation it was using asetTimeoutto overcome the initial problem. ThesetTimeoutis removed now.