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

React-three-fiber compatibility #559

Closed
xixixao opened this issue Sep 7, 2020 · 2 comments
Closed

React-three-fiber compatibility #559

xixixao opened this issue Sep 7, 2020 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@xixixao
Copy link

xixixao commented Sep 7, 2020

I would like to use React with react-three-fiber to sync state between Three.js Canvas and the rest of the page. Unfortunately this doesn't work atm, Recoil can only be used to sync state inside the Canvas.

This works:

<Canvas>
  <RecoilRoot>
    <ComponentUsingRecoilState />

This doesn't work

<RecoilRoot>
  <Canvas>
    <ComponentUsingRecoilState />

And I need the latter to do something like:

<RecoilRoot>
  <Canvas>
    <ComponentUsingRecoilState />
  </Canvas>
  <AnotherComponentUsingRecoilState />
</RecoilRoot>

Codesandbox for exploration (I don't really know how to debug this as I'm not familiar with Recoil internals):

https://codesandbox.io/s/wizardly-bash-ue9uy

@cometkim
Copy link

cometkim commented Sep 8, 2020

Related with facebook/react#13332

@drarmstr drarmstr added the duplicate This issue or pull request already exists label Sep 8, 2020
@drarmstr drarmstr self-assigned this Sep 8, 2020
@drarmstr drarmstr linked a pull request Sep 8, 2020 that will close this issue
@drarmstr
Copy link
Contributor

drarmstr commented Sep 8, 2020

Duplicate of #140

Try using the new useRecoilBridgeAcrossReactRoots() hook from #516. This is currently only in master, but we're working on getting that next release out right now.

@drarmstr drarmstr closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants