Hi, I am trying to use Babylonjsn with CRA (react) with typescript – I also followed all the steps included in the GitHub project :-
I am getting the following error; I also tried to install the react-reconciler but then I run into other issues. Could you please point me to what I might be missing.
Failed to compile
./node_modules/react-babylonjs/dist/react-babylonjs.es5.jsModule not found: Can't resolve 'react-reconciler' in '/Users/dhiru/Source/WebRepos/liveviewer/node_modules/react-babylonjs/dist'
Sorry for late reply. The ‘react-reconciler’ is a peer dependency and should be provided by CRA. Can you share your repo or your package.json? I created that typescript example from CRA v3 and then added BabylonJS.
No problem; I tried a couple of stuff … I think its got to do with cannon.js typings …(not sure); Please find the attached package.json; I tried a couple of npm install’s since then.
Please advise.
hi @dhiru that’s the same as the working example Typescript that I have! I’m using the same cannon and typings versions as you have. if you can share your repository then I can look, but otherwise do you want to create an issue on the main repository GitHub - brianzinn/react-babylonjs: React Components for BabylonJS and I can help either of those ways. Cheers.
Sure, let me share the repository – also if you want I can also re-try from scratch; since I tried multiple times in December and kept getting the same error.
Let me checkin this project on GitHub and let you know in sometime.
I tried to re-start a fresh project just to make sure I have not done any patchy installations; and now I get a different error (not sure what I am doing wrong); I did the same steps twice now :-
Please advise …
TypeScript error in /Users/dhiru/Source/Repos/Try1/client-app/src/App.tsx(10,41):
Argument of type ‘typeof Engine’ is not assignable to parameter of type ‘ComponentClass<{ babylonJSContext: WithBabylonJSContext; }, any> | FunctionComponent<{ babylonJSContext: WithBabylonJSContext; }>’.
Type ‘typeof Engine’ is not assignable to type ‘ComponentClass<{ babylonJSContext: WithBabylonJSContext; }, any>’.
Construct signature return types ‘Engine’ and ‘Component<{ babylonJSContext: WithBabylonJSContext; }, any, any>’ are incompatible.
The types of ‘props’ are incompatible between these types.
Type ‘Readonly & Readonly<{ children?: ReactNode; }>’ is not assignable to type ‘Readonly<{ babylonJSContext: WithBabylonJSContext; }> & Readonly<{ children?: ReactNode; }>’.
Type ‘Readonly & Readonly<{ children?: ReactNode; }>’ is not assignable to type ‘Readonly<{ babylonJSContext: WithBabylonJSContext; }>’.
Types of property ‘babylonJSContext’ are incompatible.
Type ‘WithBabylonJSContext | undefined’ is not assignable to type ‘WithBabylonJSContext’.
Type ‘undefined’ is not assignable to type ‘WithBabylonJSContext’. TS2345
It looks like you are trying to pass an @babylonjs/core Engine to the HOC (High Order Component) method. Check your imports and make sure your aliases are correct would be my first guess. If you are stuck and can share a repo let me know. Also, if you have updated to BabylonJS 4.1 update react-babylonjs as well - there is a breaking typing with ThinEngine.