Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Refactor item for graph layout #224

Open
davidkpiano opened this issue Aug 27, 2021 · 0 comments
Open

Refactor item for graph layout #224

davidkpiano opened this issue Aug 27, 2021 · 0 comments

Comments

@davidkpiano
Copy link
Member

Ok, I see - we send the GRAPH_UPDATED in the useEffect but the last render that did happen was rendering based on the "success" state of the previous layout.

The used solution IMHO tries to fight the React and tries to wait, implicitly, on what should happen most of the time - but there are no conceptual guarantees that this will actually happen. For instance - we can click on another actor in the meantime and create a race condition.

It would be better if we could just avoid any chance of such things happening by making the synchronization of the DOM and Elk layouts more explicit, like for example here:
92d434a

I think it would be possible to avoid those duplicated effects but we'd have to implement derived state from props pattern and we'd have to avoid rendering based on state.matches('success'). So I've chosen a solution closer to XState, at the expense of some wasted rerenders in React.

Originally posted by @Andarist in #214 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant