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

Canvas child is placed outside the DOM tree making it difficult to use React context #114

Closed
ghost opened this issue Jun 13, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 13, 2019

If I wrap the ... section of my code in some React context provider, the elements in Canvas do not have access to the context as I'd have expected. I checked the virtual DOM on dev tools, and turns out the children of Canvas is just placed outside of the tree. Is that normal? If yes, how do I make my context available inside Canvas?

@drcmda
Copy link
Member

drcmda commented Jun 13, 2019

this is a problem with react itself, all reconcilers suffer from it, here's a similar issue for react-konva: konvajs/react-konva#188 . you can either just reflect the context inside the canvas, which will work: konvajs/react-konva#188 (comment) or use a state manager that isn't reliant on context: https://github.com/react-spring/zustand

@franciscop-sc
Copy link

You could write a bridge to pass the context:

Context Bridge example

vorth added a commit to vorth/vzome that referenced this issue Nov 29, 2019
Clicking on any ball toggles the working plane.

I had to give up on using redux-bundler connect() inside the graphic
components, due to a known issue with context and reconcilers:

pmndrs/react-three-fiber#114 (comment)
This issue was closed.
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

No branches or pull requests

2 participants