Calling `setNodes` doesn't update nodes - Trying to make a Node height dynamic based on textarea input size
See original GitHub issueI’m submitting a…
[x] Bug report
I’m trying to make a node height update when the height of the textarea changes.
Video walkthrough: https://youtu.be/Ar_SKdDnAz8
Implementation of updateCurrentNode
: https://github.com/Vadorequest/poc-nextjs-reaflow/blob/repro-textarea-dyn-height/src/components/PlaygroundContainer.tsx#L97-L113
Current behavior
Calling setNodes
doesn’t seem to update nodes every time. Sometimes it’s “updated” (but the UI doesn’t reflect the change, though).
I can’t tell if it’s a react issue (like, my code), or something related to Reaflow itself. What’s weirdest is that the re-render doesn’t propagate to children component (EditorContainer renders, but PlaygroundContainer doesn’t seem so, but I can’t explain why)
Also, I wonder if there is a utility function to update an existing node in an array of nodes. I couldn’t find any example/demo on how to do that.
I wonder if I need to use an actual state manager to avoid those kinds of issues.
Expected behavior
The state should update in EditorContainer every time the height of the textarea changes, and it should re-render all children components and recalculate the position of all the elements in the Canvas.
Minimal reproduction of the problem with instructions
Run locally:
git clone https://github.com/Vadorequest/poc-nextjs-reaflow.git
- cd poc-nextjs-reaflow && git checkout repro-textarea-dyn-height
- yarn && yarn start
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
change detection
@amcdnl What does
CD
means here? 🤔