Kitware / react-vtk-js

Declarative library exposing vtk.js visualization pipeline as React components
https://kitware.github.io/react-vtk-js/
77 stars 24 forks source link

Not working with React 18 and StrictMode #67

Open FezVrasta opened 2 years ago

FezVrasta commented 2 years ago

We are trying to upgrade to React 18 but this library doesn't seem to work with it when combined with StrictMode.

The problem resides in the way the data is initialized into the constructor calls and then deleted on componentWillUnmount. StrictMode forces the components render twice, and most of the react-vtk-js logic doesn't seem to handle this (it never expects the component to unmount while some of the mount operations are still running).

Do you think you could prioritize the work needed to support React 18 + StrictMode?

FezVrasta commented 2 years ago

I think this could be a good opportunity to add TypeScript to the project and rewrite the components to be functional + hooks instead of classes?

jourdain commented 2 years ago

I think updating the library would be great especially fixing the contructor/componentWillUnmount asymmetry.

My only worry is that one consumer of that library is limited to react 16. I'm wondering if we could have a path where with the same code base we can build toward different react versions.

FezVrasta commented 2 years ago

Are they blocked on 16.0 or 16.8+?

Hooks were introduced in 16.8 so we could use that as minimum version?

jourdain commented 2 years ago

They are using 16.14+

FezVrasta commented 2 years ago

Ok that's great, there shouldn't be any issue if we decided to convert the library to hooks then