Uncaught R3F hooks can only be used within the Canvas component #1347
Replies: 4 comments 3 replies
-
Next time please provide a sandbox. I think the error explains itself, you can only call r3f hooks inside the Canvas component so do something like this
|
Beta Was this translation helpful? Give feedback.
-
@njm222 sandbox has been added |
Beta Was this translation helpful? Give feedback.
-
We're running into the same problem. It seems that vite doesn't respect peerDependencies from local packages and instead packs those dependencies into the app as well, resulting in duplicate react-three-fiber and react versions being embedded, and that causing ordering and namespace clashes. Using published registry versions or direct local folders (instead of local packages) works without these problems. I'll see if I can come up with a minimal example that breaks to report a bug... |
Beta Was this translation helpful? Give feedback.
-
You can try "vite --force" to force re-optimizatize dependencies, it's solve my problem |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
hello, I'm use vite.js + react-three-fiber to create something.
for debugging purposes, config rollup make use local react-three-fiber.esm.js, but got
Reproduction
https://github.com/lifeng1992/r3f
sandbox
https://codesandbox.io/s/adoring-feynman-kvxw8?file=/vite.config.js
Beta Was this translation helpful? Give feedback.
All reactions