Skip to content
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

Merged
merged 4 commits into from
Mar 28, 2023

Conversation

marstamm
Copy link
Contributor

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 and descriptionLoaded to be called twice.

This PR ensures the callbacks are only called once.

@marstamm marstamm requested a review from a team March 16, 2023 10:24
@marstamm marstamm self-assigned this Mar 16, 2023
@marstamm marstamm requested review from philippfromme and smbea and removed request for a team March 16, 2023 10:24
@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Mar 16, 2023
@marstamm
Copy link
Contributor Author

marstamm commented Mar 17, 2023

9600411 and a1cf5c2 fix the root-cause of #227.

This is ready for review

// hooks //////////////////

/**
* This hook behaves like useEffect, but does not trigger on the first render.
Copy link
Member

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(() => {

}, []);

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡

@nikku nikku merged commit 5014374 into main Mar 28, 2023
@nikku nikku deleted the fix-callbacks branch March 28, 2023 11:09
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants