Drop unexpected content to the device tree
Hi, I suddenly found that if I drop something unexpected to the tree it causes an exception:
main.js:50 SyntaxError: Unexpected token ':', ":::::Posit"... is not valid JSON
at JSON.parse (
In my case I caught a card, created with another component and I dropped it to tree. First I thought that I can solve this by the callback dropValidаtor, but the exception happens before it. How can I protect the device tree from dropping invalid data?
Please share a minimum example to reproduce.
My application is too complex. But the easiest way to get the problem is just to drag some texts from a text editor and drop it anywhere in the tree. This should cause the mentioned exception. The component will try to parse this text, but because it is not according to the rules of the JSON-format, it will generate this exception.
That's not a supported feature. We only support dragging nodes within the tree, not arbitrary objects.
Ok, but isn't there any possibility to catch an event that comes earlier that the call of the function onDropNode, to check the data and reject it with my own code?
It may not be straightforward. Does this exception cause your application to crash ? I suppose the user should not be trying interesting things like that on an app if it doesn't support it.
My application doesn't crash. I just see the exception in the console and this annoys me. But I found a solution. I caught the error in errorCaptured hook and by returning false, the error doesn't occur in the console anymore. We can close this issue.