[v5] Calling render while an existing render is happening causes force layout to flash
- Dominant language
- TypeScript
- Stars
- 12.3k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug / 问题描述
It is possible to not await graph.render and call it while another render is already happening. This results in strange results such as the force layout flashing between multiple layouts running simultaneously.
This is unlikely a problem in well structured code, but in more complex code, especially in React, you can end up accidentally calling graph.render in rapid succession for one reason or another.
I'm not sure this is something g6 needs to address directly, but at the very least a warning in the documentation, or some code to detect and print a warning in the console, would be nice.
As a note, as a user, you can fix this by implementing some sort of lock around the graph.render method yourself, or debouncing the graph.render method. (If you cannot stop your code from calling graph.render multiple times)
### Reproduction link / 重现链接
https://codesandbox.io/p/sandbox/g6-react-forked-8dnk5w
### Steps to Reproduce the Bug or Issue / 重现步骤
On loading the sandbox the layout flashes
Also, on clicking the Add Node button, the layout can flash as well
### G6 Version / G6 版本
🆕 5.0.7
### Operating System / 操作系统
macOS
### Browser / 浏览器
Chrome, Firefox
### Additional context / 补充说明
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked CodeSandbox reproduction and the graph.render entry point, especially the loading and Add Node cases that trigger concurrent renders. Determine whether the intended outcome is preventing the layout flash or documenting and warning about overlapping calls; done should be demonstrated against both reproduction steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100