dependentree icon indicating copy to clipboard operation
dependentree copied to clipboard

Getting error: "_name" key in entity object is not of type string. Instead received a value of "[object Object]" with a type of "object"

Open nadavq opened this issue 2 years ago • 1 comments

This is because the function 'export function _isValidNameStr(parentStr, str)' is recieving an object as str instead of string, but why is it receiving an object? I used the given 'royals' array but it still throws this error.

nadavq avatar Nov 20 '23 20:11 nadavq

Most likely you are using React with strict mode enabled. Possibly you are setting up the tree in a useEffect hook.

The issue is that tree.addEntities is being called twice. Normally, this would not be a problem, but it looks like this library MUTATES the input data (which is very naughty of it). The correct fix is to make it so this library clones the input array (or avoids mutating the input object in some other way). The workaround you can do is to simply not call tree.addEntities more than once.

gjtrowbridge avatar Feb 13 '25 22:02 gjtrowbridge