Markdown render() method called repeatedly on block focus
Describe the bug
When having a few markdown documents rendered in WaveTerm, merely clicking on the cells to change focus will invoke render() from the Markdown class each time.
Since merely clicking or focusing on a cell is not changing any of the public properties that it depends on - and it already executed and rendered, there should not be an additional call to re-render in React.
We nested React components inside the Markdown, and therefore they are impacted by the Markdown class having to re-render. Is there a way to stop the propagation of the render whenever focusing or clicking on past cells in the WaveTerm view?
To Reproduce Steps to reproduce the behavior:
Open two markdown documents in WaveTerm:
mdview example1.md
and then in next cell
mdview example2.md
Add a simple console.debug in the render() method for the Markdown class.
Then to verify, restart WaveTerm and click between the two cells.
Expected behavior
Markdown once rendered, does not undergo any more visual re-rendering as it is disruptive to others in that take advantage of building new markdownComponents
Screenshots
Every click will emit a console debug message similar to mine in the right hand side Chrome dev tools.
Desktop (please complete the following information):
- OS: [e.g. MacOS/Linux, x64 or arm64]
- Version [e.g. v0.5.0]
Additional context
Goal is to be able to have more interactive content in the form of custom React widgets shown when the markdown renders. Because the user might click on a different block and then come back, we don't want our nested widgets to re-render, which makes it start from the start again.
I know markdown should be simple, but the point is that we can actually build some bit of interactivity. Calling another render() is too destructive.