Trash a component by key
See original GitHub issueMy question is quite simple, regarding this @sophiebits answer about React (https://stackoverflow.com/questions/21749798/how-can-i-reset-a-react-component-including-all-transitively-reachable-state), does Preact completly trash a component if the key props changes ?
Two bonus question :
- does it reinit the real DOM during this process ?
- if it does not, how to reset completely the component ?
My use case is that i render a preact (private) library component which i cannot touch, this component contains an html <video>
element.
In my top level component, i’m trying to change the key on “reset” to destroy the element, and rebuild it from scratch.
Expected behaviour :
By so, i hope the <video>
to reset it’s behaviour, and display the first frame as a preview, in a fresh video ready to play from start.
Observed behaviour :
The video actually keep it’s playing position between re-render, even with a different key
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
The recycler is gone with Preact X 🎉
I see, thanks for your answer, that’s what i experienced, i will check your piece of code and give feedback for googlers.
Thanks for your feedback anyway.