bohdanbirdie / react-stl-obj-viewer

React components to view STL and OBJ models.
32 stars 11 forks source link

not able to render stl file , issue replicated in latest react versions #13

Open dhanraj-khatal opened 2 years ago

dhanraj-khatal commented 2 years ago

browser console showing the below error after stl file render index.js:52371

   Uncaught Invariant Violation: Unable to find node on an unmounted component.
at invariant (http://localhost:3000/static/js/vendors~main.chunk.js:154545:23)
at findHostInstanceWithWarning (http://localhost:3000/static/js/vendors~main.chunk.js:174954:17)
at Object.findDOMNode (http://localhost:3000/static/js/vendors~main.chunk.js:175512:22)
at onLoad (http://localhost:3000/static/js/vendors~main.chunk.js:199485:69)
at FileReader.reader.onload (http://localhost:3000/static/js/vendors~main.chunk.js:199647:25)
JoueBien commented 2 years ago

Seams to be an issue with react 17 - rather the dev/s of this package or a base package doing bad things with either state management or event listeners. Either that or it's a react version mismatch.

I downgraded react to 16 and everything worked.

npm install --save react@16.13.0 react-dom@16.13.0

Then importing with

const STLViewer = dynamic(() =>
  import('../node_modules/react-stl-obj-viewer/build').then((mod) => mod.STLViewer),
  { ssr: false }
)

Because - not natively supporting SSR - the build process or one of the base libraries is using document without checking for its the existence first.