Open erikhofer opened 1 year ago
This is a major blocker for my team as well
This looks like it could be the problem.
yes, I'm also facing a similar issue with getting the cy element back from CytoscapeComponent
my workaround is currently putting all of my useEffect(() => doStuffWithCy(cy))
code into a setTimeout
with 1 ms...and it seem to work)
React 18 brings some infamous changes to the way StrictMode works during development (see https://coderpad.io/blog/development/why-react-18-broke-your-app/).
This also seems to cause some issues with this library. I encountered the first error in a piece of code that uses
useEffect
to re-run the layout whenever the elements change. I have created an SSCCE here:https://codesandbox.io/s/cytoscape-react18-strict-mode-ysrugk
This code worked with React 17. Now, you have to remove the
<StrictMode>
inindex.js
to make it work again. This is only an issue during development. If you build a production version of the app, it works normally.I also encountered the following error after swallowing this one with a try-catch.
In my app, this is only triggered when opening the graph in a modal. I was not able to reproduce this in an SSCCE but maybe the stack trace helps.