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

Update readme to clarify when store updates a component #41

Merged
merged 1 commit into from Feb 18, 2021

Conversation

reins-ch
Copy link
Contributor

After troubleshooting for a long time and not understanding why my component was not rerendered when the state changed, I read through the code.
It turns out getRenderingRef of @stencil/core only returns truthy when it is currently in a render function.
And the result of getRenderingRef is used to mark if a component should be rerendered:

So I just want to save anyone else the time and trouble of finding this by just clarifying it in the readme.

@beenotung
Copy link

So it only trigger auto re-rendering when you access the store in the "render" method, not other place like constructor and "connectedCallback" method?

@Serabe
Copy link
Contributor

Serabe commented Jan 4, 2021

@beenotung exactly. If we take a look at the component's lifecycle, the part in pink is the rerender process:

2021-01-04 at 11 05

Anything in the constructor, connectedCallback or similar methods outside the pink circle won't be run in the rerender so it makes no sense to rerender anything because a property only accessed there changed.

@beenotung
Copy link

That makes sense. Store is used to hold shared state for the purpose of rending (and re-rendering).

Thanks for the clarification.

@manucorporat manucorporat merged commit 1663a30 into ionic-team:master Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants