Nodes do not re-render when prop gets updated
See original GitHub issueHi,
I’m trying to change the definition of the nodes passed to the GraphView
each time a determined event occurs (in my case, when a value on a drop down list change).
However, the nodes involved in the update do not immediately change; to trigger a new rendering I have to hover over every node that I need to update.
Is there a way to force the rendering of updated nodes on a determined event?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
React: why child component doesn't update when prop ...
Update the child to have the attribute 'key' equal to the name. The component will re-render every time the key changes.
Read more >How and when to force a React component to re-render
React automatically re-renders components, but what happens when a component is not updating as expected? Find out what you can do here.
Read more >When does React re-render components?
There are two common reasons why React might not update a component even though its props have changed: The props weren't updated correctly...
Read more >5 Ways to Avoid React Component Re-Renderings
1. Memoization using useMemo() and UseCallback() Hooks ... Memoization enables your code to re-render components only if there's a change in the props....
Read more >Re-Render React Component When Its Props Changes
The redux-store is updated properly, but the child component doesn't re-render. It's normally not the responsibility of the Child to fill the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also needed to force rerender nodes, and was able to solve the problem using a ref and directly calling
asyncRenderNode
as needed. Is this use case common enough that it would be worth adding this method to the docs in the Imperative API section?Unfortunately creating a new array each time I need an update did not work in my case.
However, thanks to the reference that you provided, I solved my issue by (ab)using the value
forceReRender
at line 274 (https://github.com/uber/react-digraph/blob/master/src/components/graph-view.js#L274): every time I need a new render, I just pass a different value tolayoutEngineType
.Thank you