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

Events published during compiling are not captured due to rendering cycle #1020

Closed
thomcsmits opened this issue Dec 22, 2023 · 0 comments · Fixed by #1024
Closed

Events published during compiling are not captured due to rendering cycle #1020

thomcsmits opened this issue Dec 22, 2023 · 0 comments · Fixed by #1024
Assignees
Labels
bug🐛 Something isn't working

Comments

@thomcsmits
Copy link
Collaborator

Problem
When using the gosling ref to subscribe to events of the API in a component wrapping the GoslingComponent, events published during compiling are not captured.

Minimal example
Minimal example using the same UseEffect as in the editor

Observed behavior
Nothing is logged

Expected behavior
{specProcessed, object} is logged

Explanation:
The useRef hook works by assigning the ref to a DOM node. This happens when the component is rendered, e.g. assigned to the root. Thus, the UseEffect hook (with the ref in it's dependency array) is called after the first render.
With Gosling the compiling happens before the component is rendered. Therefore, the events are already published before the ref is assigned (the subscribe function is called too late).

Possible solution?
An initial render of an empty canvas, assigning the DOM node and then updating the component after it has compiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants