-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(PropertiesPanel): only call callbacks once on first render #228
Conversation
// hooks ////////////////// | ||
|
||
/** | ||
* This hook behaves like useEffect, but does not trigger on the first render. |
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.
Isn't this equivalent to an effect without dependencies, i.e.
useEffect(() => {
}, []);
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.
It's actually the exact opposite 😄
useEffect(fn, [])
is only executed once, ONLY during the first render.
useUpdateEffect
is executed every time a dependency changes, EXCEPT on the first render
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.
💡
with #225 we introduced changes so the layout reacts to external changes.
With the changes, we introduced another re-render cycle during bootstrapping, causing
layoutChanged
anddescriptionLoaded
to be called twice.This PR ensures the callbacks are only called once.