match to skate latest api and fix preact unmounting cleanup #6
Conversation
src/index.js
Outdated
this._preactDom = render( | ||
renderCallback(), | ||
renderRoot, | ||
this._preactDom || renderRoot.children[0] | ||
); | ||
} | ||
disconnectedCallback() { | ||
super.disconnectedCallback && super.disconnectedCallback(); | ||
this._preactDom = render(<div/>,this._renderRoot,this._preactDom); |
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.
original is correctly replaced with empty div, although Preact won't call componentWillUnmount
on mounted wrapped component ...
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.
Also it's not a shadowDOM thing. Following wont trigger willUnmount as well ( pure Preact )
import { h, Component, render } from 'preact'
class App extends Component {
render(){
return <div>original</div>
}
componentDidMount(){
console.log('hi')
}
componentWillUnmount(){
console.log('bye!')
}
}
const mountTo = document.getElementById("root")
let root;
root = render(<App />, mountTo);
console.log(root)
setTimeout(()=>{
// element is replaced bud willUnmount won't be called ... Preact BUG ?
render(<div>replaced</div>, mountTo, root)
},1400)
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.
Yeah, I don't have any experience here. Might be worth pinging @developit about this? It looks like unmounting at a node is in compat, but I don't want to place a dependency on that preactjs/preact#53.
916c8e8
to
2ea5e01
Compare
Re-review pls @treshugart |
Cool, thanks @Hotell! |
Closes #5