Git Product home page Git Product logo

Comments (3)

fritz-c avatar fritz-c commented on August 17, 2024

It could be that react doesn't detect the object/array change. I believe that can happen if you edit your object/array in-place.
So if you're adding via methods like:

const newTreeData = this.state.treeData;
newTreeData.push({title: 'myNewNode'});
// or
newTreeData[0].children = [{title: 'child1'}, {title: 'child2'}];
this.setState({treeData: newTreeData}); // won't update

you should instead use methods like

const newTreeData = this.state.treeData;
newTreeData = newTreeData.concat({title: 'myNewNode'});
// or
newTreeData = [
    {...newTreeData[0], children: [{title: 'child1'}, {title: 'child2'}]} // requires babel-plugin-transform-object-rest-spread
].concat(newTreeData.slice(1));
this.setState({treeData: newTreeData}); // will update

All the data manipulation methods (including node addition/removal) included in this package behave like the second bunch of examples, so if you're using those and still have a problem it might be something else.

from react-sortable-tree.

harris800 avatar harris800 commented on August 17, 2024

Hi @fritz-c,
Thanks for your advice, I got the point. I am using _.merge method and it mutates object, that's why it is not update. Thanks!

from react-sortable-tree.

anil1712 avatar anil1712 commented on August 17, 2024

Hi,
I am using the same, its working fine but at the end the whole tree collapsed. I tried to pass expanded in new node but seems not working.

How to pass dynamic index instead of passing 0 as hard coded?

Thanks,

from react-sortable-tree.

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.