Skip to content

How to add custom key: value pairs to TreeNode  #236

Open
@Jack-Tilley

Description

@Jack-Tilley

Hello,

I am using react-checkbox-tree in a project and I am trying to add custom key: value pairs to some TreeNodes. (ie:)

let myCustomNode = {
                value: "normalValue",
                label: "normalLabel,
                newCustomKey: "myCustomKeysValue"
        }
setNodes(myCustomNode)

...

return(
    <CheckBoxTree
    ...
    nodes={nodes}
    >
)

However, when I try to access the newCustomKey value with a console.log(referenceToMyCustomNode), I can see that the default values of value and label are there, as well as the other default values children etc. (attempting to access referenceToMyCustomNode.newCustomKey will always result in undefined)

I am wondering if you could help me understand why I am not able to see the new custom key: value pair.

Side note: When I check the parent node's key:value pairs and select children, I am then able to see all the custom key: value pairs the original node has been given. This means that key: value pair is attached to the TreeNode but we cannot access it directly for some reason.

Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions