-
Notifications
You must be signed in to change notification settings - Fork 23
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
renderLayer
called on _every_ update?
#17
Comments
This is true of any Preact/react component. Update Cascade can be mitigated using shouldComponentUpdate or memo. Fwiw the render() call diffs, so what's happening here isn't necessarily a DOM mutation, but rather the flow of data through the virtual DOM tree. |
Ok! But the componentDidUpdate(props) {
return setTimeout(this.renderLayer);
} |
Technically it's possible to avoid triggering rerenders by hoisting things out of render: const myPortal = <Portal into="body"><SomeComponent /></Portal>
class Outer {
render() {
return <div>{myPortal}</div>
}
} |
Thanks for the suggestion! I'm not having a performance problem or anything though, I'm just trying to understand how these things work: Here's a codesandbox showing what I mean: https://codesandbox.io/s/k54oz8mzm3?fontsize=14 I the demo, the |
The point of
<Portal>
is to pass children to it (that are rendered somewhere else). Andprops.children !== prevProps.children
always, right? If so, doesn't this mean that the for-if check incomponentDidUpdate
always triggers?preact-portal/src/preact-portal.js
Lines 10 to 16 in ba21279
The text was updated successfully, but these errors were encountered: