react-universal-component
react-universal-component copied to clipboard
onAfter called after preload in V3 but not V4
In V4.0.0 onAfter is not being called if we called preload. V4.0.0 Sandbox
but in V3.0.3 onAfter is called correctly after we call preload. V3.0.3 Sandbox
is it expected?
Likely not. Can you investigate more and possibly open a PR?
I can confirm its not being called serverside render either.
Anyone help in debugging. I’ll try and find some time to give RUC some TLC
I also confirm this is happening in 4.0.0. Just started digging into it, see what I can find
UPDATE: This is happening for me only on the initial mount. Subsequent mounts do call onAfter, but the first one does not. e.g. navigating to a second page will run onAfter
After analyzing 3c21ffa45c I found that this was caused during the refactor from componentWillMount()
to init()
.
Previously, componentWillMount
set _mounted
to true
and then subsequently fired update()
. After 3c21ffa45c, we instead have constructor()
calling init()
which in turn calls __update()
- but _initialized
(formerly _mounted
) is not set until componentDidMount()
which takes place AFTER constructor()
. Therefore, _initialized
will always be false
on the first run of __update()
triggered by constructor() -> init()
, which causes __handleAfter()
to not be called.
My solution is to move the init()
call from constructor
to componentDidMount
, after _initialized
is set to true
. PR coming soon
@mattrabe I'm not sure if I'm using it correctly but I employed the same sandbox with the updated package but it is still re-occurring sandbox
edit, it still fails the test case.