Closed wdfinch closed 3 years ago
Hey! Thanks for the report. How can we reproduce this issue?
Hey,
I think you are trying to access the position property of an element which is not a node (may be an edge).
so, that error usually comes when you try to access position which doesnt have position.
Try checking with the built in - isNode(arr[element]) && // your functionality.
just a guess.
try if it works. I got this issue few times.
this.state.elements.find((el, key) => { if (isNode(el)) { // your functionality } } something like this.
So the issue happens when the flow is being rendered. I'm not trying to access the position property of a node. I'm not sure what's causing this as my input seems valid.
can you may be post the input, and a way to debug it. we'll see if we can help in any way. :)
Can you create a codesandbox or repo so that we can check your code?
So I'm having a tough time reproducing because I'm using a number of custom labels as well as custom edges that would take some time to port over to code sandbox. I tried removing all of those and it seemed to render fine then. I'm going to do some more investigating to see if I can find the cause here. Hopefully, the stack trace above helps in some way. Thanks for the help here though. Really appreciate the quick responses.
@moklick @harish-madugula
Ok so after a lot of testing I finally was able to reproduce this in code sandbox.
The issue seems to be related to updating the position of a node, unmounting the flow render component, and then trying to remount. I also notice this issue when the nodes the flow works on are changed specifically when the flow rendered component is unmounted.
I think the issue is some redux state for the component is being preserved when the component is unmounted and then when it tries to read it again on mount, it throws an error.
Steps to reproduce.
Update: You could actually skip step 4. Just remounting after the position of a node has been changed is enough to crash it.
I've attached a screen recording as well to show these steps. See the google drive link if you're having trouble.
https://drive.google.com/file/d/1FrQT1HwJhCU-L2q-v6ugAQG_7aYhcdio/view?usp=sharing https://codesandbox.io/s/cranky-worker-dymfw?file=/src/App.js
Ok, thanks for the detailed information on this :) I will see how we can fix this
Thanks, @moklick. It's really hard to use the functionality your library provides in my app right now because of the crashes, so it would be awesome if this could be patched soon.
I just implemented a fix. Can you check v5.9.4?
Seems like this is fixed now. I will continue testing to make sure. Thanks so much for getting this out quickly. I really appreciate it.
I get a similar error (both before and after upgrading to 5.9.4): cjs.js:12 Uncaught TypeError: Cannot read property 'x' of undefined
the cjs.js
is:
var _require = require('./Draggable'),
Draggable = _require.default,
DraggableCore = _require.DraggableCore; // Previous versions of this lib exported <Draggable> as the root export. As to no-// them, or TypeScript, we export *both* as the root and as 'default'.
// See https://github.com/mzabriskie/react-draggable/pull/254
// and https://github.com/mzabriskie/react-draggable/issues/266
module.exports = Draggable;
module.exports.default = Draggable;
module.exports.DraggableCore = DraggableCore;```
@chiester Could you link to a code sandbox with steps on how to reproduce the issue.
Hi @chiester, were you able to resolve your problem? I'm having the same error.
🆙 My error was due to messing up with node.rf.width and node.rf.height properties
My app is crashing due to an uncaught exception. See below for details. Perhaps this could be handled more gracefully such a console warning?