Code Monkey home page Code Monkey logo

Comments (7)

jpb12 avatar jpb12 commented on August 20, 2024

You can already do this by setting a keyProp, as described in the docs.

Property Type Mandatory Default Description
keyProp string "name" The property on each node to use as a key.

from react-tree-graph.

Northshoot avatar Northshoot commented on August 20, 2024

I saw that, but it does not work with the tree view example.
Setting the property causes error on (only) duplicate nodes

TypeError: node.children is undefined

from react-tree-graph.

jpb12 avatar jpb12 commented on August 20, 2024

Can you add your code that's reproducing the issue? The JSON date you're using and the props you're passing into the Tree component should be enough.

from react-tree-graph.

Northshoot avatar Northshoot commented on August 20, 2024

Without changing any code, this is the json

`export default {
timestamp: '14/12/2016 22:00',
name: 'Colour',
sortvalue: 'Colour',
children: [{
name: 'Cyan',
sortvalue: "Cyan_1",
children: []
}, {
name: 'Blue',
sortvalue: 'Blue',
children: [{
name: 'Aquamarine',
sortvalue: 'Aquamarine',

    children: []
}, {
    name: 'Cyan',
    sortvalue: "Cyan_2",
    children: []
}, {
    name: 'Navy',
    sortvalue: 'Navy',
    children: []
}, {
    name: 'Turquoise',
    sortvalue: 'Turquoise',
    children: []
}]

}, {
name: 'Green',
sortvalue: 'Green',
children: []
}, {
name: 'Purple',
sortvalue: 'Purple',
children: [{
name: 'Indigo',
sortvalue: 'Indigo',
children: []
}, {
name: 'Violet',
sortvalue: 'Violet',
children: []
}]
}]
};`

and this is the tree construct:

<Tree animated data={root} height={this.props.height} width={this.props.width} keyProp={'sortvalue'} gProps={{ className: 'node', onClick: setActiveNode }} steps={30}/>

With only addition of the

keyProp={'sortvalue'}

from react-tree-graph.

jpb12 avatar jpb12 commented on August 20, 2024

I've created an issue-10 branch with those changes and it works for me. Are you sure your code has been rebuilt with your changes? Can you try running npm run build-dev -- --watch or committing your changes to a fork somewhere?

from react-tree-graph.

Northshoot avatar Northshoot commented on August 20, 2024

hum, here is the form and included output when it crashes

https://github.com/Northshoot/tree-viewer/commits/master

from react-tree-graph.

jpb12 avatar jpb12 commented on August 20, 2024

Those changes still work for me. I suspect it's an issue with building the code.

from react-tree-graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.