description:
I have a data playback function. The scene is to play back the steps entered by the user。
But my dispatch is not processed incrementally, but uses the full amount of data in each frame。
question:
This will cause a problem that the linenumber will flash。The reason is that I added EditorView.lineWrapping
Each frame number will be replaced from the position of 0 。
useEffect(() => {
const currentValue = view ? view.state.doc.toString() : '';
if (view && value !== currentValue) {
view.dispatch({
changes: { from: 0, to: currentValue.length, insert: value || '' },
});
}
}, [value, view]);
extsion:[EditorView.lineWrapping,view.lineNumbers()]
Can the full replacement make the linenumber not flash?
updateAttrs does almost nothing. As the profile shows, the browser is running a layout there, and that’s what takes the time. Which is odd, because that function doesn’t query layout, it just sets and removes DOM attributes. If I profile something like this on Chrome I don’t see layouts happening remotely as often as in the profile in your screenshot.