0


I am trying to render 3D files in my react project. I am using ThreeJS for my react project of version 16.13.1. After installing @react-three/fiber & @react-three/drei these packages, I am getting error of Module not found: Can't resolve 'react-dom/client'. After searching solution for this I get to know that for these we have to upgrade React version to 17 or above. I did it in demo project & it worked. But the restriction is that I can not update actual project version from 16 to 18 as it will change or break so many things as well as I have to take care of other dependencies. Is there any solution available for using ThreeJS with React v16.
Or if there is any other way or different packages available to render 3D files (like .glb, .gltf) please share with me.
Thank you in advance.

rocco
  • 133
  • 1
  • 8

2 Answers2

0

How to find a version of a library that supports particular version of react?

  1. Google <library-name> npm
  2. Go to npm page
  3. Go to repository (usually github)
  4. Open package.json
  5. Check version of react; if it's matching your version go to 7.
  6. Change tag to some previous version; go to 5.

@react-three/fiber & @react-three/drei for react 16.13.1

These two should work:

npm install @react-three/fiber@4.2.21 @react-three/drei@3.2.0

Disclaimer

You can never know if the packages work without trying. Many things changes and bug fixes only apply to the newest versions.

Konrad
  • 21,590
  • 4
  • 28
  • 64
0

I found one package react-3d-viewer to render 3D files which perfectly work for me.

Google model viewer also works and it comes with variety of props which is good for customization of rendered 3D model.

https://github.com/dwqdaiwenqi/react-3d-viewer https://modelviewer.dev/docs/index.html

rocco
  • 133
  • 1
  • 8