-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
Create onmounted Event #894
Conversation
This looks so cool! I've been writing components that render svg shapes and have been using polling hacks to query JS for the the rendered size of the SVG element so I can calculate scaling factors, etc. Can't wait to toss that code out 😄 This seems like it will open up quite a few new possibilities. |
Awesome! Thank you! @Demonthos |
A bit late, but should the event name not be I'm curious is there also an |
Yes,
Effects also run after the component is first mounted, but they don't provide information about the element that was mounted. That is what the onmount event adds. Hooks are dropped when the component is dropped. You can use them to run any of your cleanup logic. We could defiantly provide a hook that makes it easier to run a closure when the component is unmounted. We could have a onunmount event that runs directly before the element is unmounted, but I can't think of a use case that would use the element. |
Right, I remember seeing a comment in Discord where you mentioned that 🤦
Right, the information I would be interested in is available in the components state anyway. |
resolves #631
resolves #517
resolves #804
resolves #423
Implements a new onmounted event with a trait object in the HTML crate. (More API discussion in #631)
The element allows:
Each of these APIs are optional for the underlying renderer to implement.
Todo: