-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add default mounted() method to Component trait #583
Conversation
Actually, the thought just occurred to me that Let me know if you agree that |
@hgzimmerman yeah let's follow the lead of React and allow re-rendering on mount: https://reactjs.org/docs/react-component.html#componentdidmount Their stated use-case of dialogs getting the width of the screen for example is something we should support. Also, like React, we will not update the browser screen until the mount is finished. |
…erendering on mounted
I think this accomplishes what you want. The only point of ambiguity that I have is about your comment here:
Does calling |
Yup, this is exactly what I had in mind. My understanding is that since the environment is single threaded, the browser won't update the screen until your code finishes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!!
bors r+ |
583: Add default mounted() method to Component trait r=jstarry a=hgzimmerman Fixes #572 I made the choice to have `on_mount()` not return a `ShouldRender` bool, because I don't think there is a situation where altering parts of a component state relevant to the `view()` should ever take place in `on_mount()` instead of `create()`. Let me know your thoughts, because its an easy enough change to make. Co-authored-by: Henry Zimmerman <zimhen7@gmail.com>
Build succeeded
|
Fixes #572
I made the choice to have
on_mount()
not return aShouldRender
bool, because I don't think there is a situation where altering parts of a component state relevant to theview()
should ever take place inon_mount()
instead ofcreate()
. Let me know your thoughts, because its an easy enough change to make.