brianzinn / react-babylonjs

React for Babylon 3D engine
https://brianzinn.github.io/react-babylonjs/
812 stars 102 forks source link

Unable to resolve module react-dom/client #246

Closed antonyrey closed 1 year ago

antonyrey commented 1 year ago

Hello,

I'm trying to use react-babylonjs inside a React Native application. I followed the small sample in the README : https://github.com/brianzinn/react-babylonjs#react-native

However, when I start my project, I get the following error at runtime :

Unable to resolve module react-dom/client from C:\dev\BabylonReactNativeSample\node_modules\react-babylonjs\dist\react-babylonjs.js: react-dom/client could not be found within the project or in these directories:
  node_modules\react-babylonjs\node_modules
  node_modules

Did anyone encounter the same issue?

I didn't find any working sample anywhere, and is there really no documentation at all for this library?

Thanks a lot, have a nice day !

brianzinn commented 1 year ago

hi @antonyrey,

I think I need to move this out to a helper library: https://github.com/brianzinn/react-babylonjs/blob/master/packages/react-babylonjs/src/customComponents/Html.tsx

You will need to go back to v 3.0.25 in the meantime before that dependency was introduced. You will get a peer dependency warning that can be ignored in that version.

I've been slowly working on the docs - they are quite horrible currently. There is a storybook of examples that I want to sunset and a new documentation site with gastby + MDX that is close to ready.

Will that version work for you in the meantime?

brianzinn commented 1 year ago

Actually, I think I just need a separate native export. ie: import { Scene } from 'react-babylonjs/native'. That would exclude Html component. I won't need Engine component in there either due to how native creates one with their useEngine hook. @dennemark FYI

brianzinn commented 1 year ago

it's worth trying import Scene from 'react-babylonjs/dist/Scene';. I can work to remove /dist/ from the import statement.

dennemark commented 1 year ago

I haven´t used react-native yet. Is it easy to set up with the react-babylonjs repository? It would be nice to have a similar component to HTML for native, but I guess it won´t be that easy. If you manage to seperate the native export, it is a nice solution. Otherwise we would have the same issue in a package that would seperate HTML from main package as soon as you want to use other helper files from it in a native environment.

brianzinn commented 1 year ago

closing from inactivity... please re-open if you need help still.