Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onAfter called after preload in V3 but not V4 #186

Open
Radi-Mortada opened this issue May 20, 2019 · 6 comments
Open

onAfter called after preload in V3 but not V4 #186

Radi-Mortada opened this issue May 20, 2019 · 6 comments

Comments

@Radi-Mortada
Copy link

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?

@ScriptedAlchemy
Copy link
Collaborator

Likely not. Can you investigate more and possibly open a PR?

@jamesjjk
Copy link

I can confirm its not being called serverside render either.

@ScriptedAlchemy
Copy link
Collaborator

Anyone help in debugging. I’ll try and find some time to give RUC some TLC

@mattrabe
Copy link

mattrabe commented Jan 7, 2020

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

@mattrabe
Copy link

mattrabe commented Jan 7, 2020

After analyzing 3c21ffa 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 3c21ffa, 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 added a commit to mattrabe/react-universal-component that referenced this issue Jan 7, 2020
…n V3 but not V4

Move init() call from constructor to componentDidMount, after _initialize is set to true, so that
__update() fires __handleAfter on first run

fix faceyspacey#186
ScriptedAlchemy pushed a commit that referenced this issue Jan 18, 2020
…t V4 (#204)

Move init() call from constructor to componentDidMount, after _initialize is set to true, so that
__update() fires __handleAfter on first run

fix #186
@AndrewThian
Copy link

AndrewThian commented Feb 5, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants