Comments (5)
Hm.. I designed it so that it would update to reflect any changes in the state, without having to explicitly trigger anything. Are you modifying the object in-place?
e.g.,
this.state.myTree[3].bar = "foo";
this.setState({ myTree: this.state.myTree });
Every data operation I did in the library (and in the tree data APIs) did something more like
const index = 3;
this.setState({ myTree: [
...this.state.myTree.slice(0, index),
{ ...this.state.myTree[index], bar: "foo" },
...this.state.myTree.slice(index + 1),
] });
I forget, but I think that's called a pure function, or treating objects as immutable.
If this doesn't help, do you mind posting the relevant parts of your code?
from react-sortable-tree.
Thanks for the expedient reply. Revised what I posted prior. Did it your way, worked. Still grokking why and immutability... :)
from react-sortable-tree.
Glad to hear!
More so than my library, I think it might have something to do with how React detects changes in state. Assigning new values to an object without recreating it makes it so the previous reference is unchanged, and objects are passed around by reference (I think).
Here's a little proof-of-concept from the terminal:
$ node
> a = {b: 1}
{ b: 1 }
> c = a
{ b: 1 }
> c.b = 2
2
> a === c
true
from react-sortable-tree.
Hi,
How do we get index
?
Can we use treeIndex
to modify the tree node title?
Actually I just wanted to change the title of any node. Please suggest me how to achieve this.
@fritz-c can you please look into it. How do I update any tree node title by uisng the treeIndex
for path
?
Thanks
from react-sortable-tree.
So I should be able to use the functions like addNodeUnderParent
when hosting this in a PureComponent
with no issue?
from react-sortable-tree.
Related Issues (20)
- How to use props with redux ? HOT 1
- React version dependency issue HOT 5
- how to make search nodes only starting from one node which we clicked ?
- Is it possible to make the react sortable tree ui less big with a setting : sm, md, bg ?
- React dnd upgrade HOT 2
- How to customize move handler? 🤔 HOT 2
- div is fadeout when drag
- Insert node at specific index under parent node.Iindex HOT 1
- It is possible to use a node as ReactRef() ? HOT 1
- Give Children another label/property name
- Failed to minify the code error HOT 2
- getTreeFromFlatData set rootKey as null
- Support multiple dragging
- Option to snap automatically to nearest possible level HOT 1
- Support React 18 HOT 1
- new child is added to the parent when collapsing the parent HOT 1
- Using the react-sortable-tree in react 18 HOT 4
- is it possible to display the tree as a vertical tree diagram?
- About maintenance of this library
- Could not resolve dependency: React 18 with [email protected] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-sortable-tree.