#Drag and Drop not triggering rerender

1 messages · Page 1 of 1 (latest)

dusky seal
#

In this ReacFlow App, the goal is for the two flows to alter a table.
In FlowStates the goal is that when a node is created with onDrop it will increase numberOfStates with its setter. This is not the case:

  • First node created with DnD shows first and correct numberOfStates.
  • Subsequent DnD nodes show the same numberOfStates as the first one.
  • Changing panel seams to trigger the update and the next numberOfStates would be the updated one.

Goal:

  • How to trigger the update so the next DnD node has the correct value without needing to change panel to trigger it.
meager ore
#

In the onDrop function, pass the numberOfStates as a param in dependency array of useCallback.

dusky seal
#

That was so simple, but it went right over my head. Thank you very much.

meager ore
#

no problem. Install the eslint extension in whatever text editor you are using. That would help you to catch issues like these.

lunar gale
#

Are you talking about the rule-of-hooks plugin for eslint, or something else?