-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor performance on re-render #302
Comments
I'm having this same problem with large files. I still haven't found a workaround for this issue. |
Having the same issue. Unusable with large files. |
Any solution? It's really a big problem. |
I think this may be fixed by #394 by @xiangst0816 This has been merged, but not yet released (maybe it will become |
15.5.0 (released this morning) contains @xiangst0816 's fix from #394 |
Thanks @simmerer ! |
I don't think this is fixed. The correct solution, as mentioned here #303 should be A hack I did in my app, that helped is to actually memoize the component myself const memoizedHighlighter = useMemo(
() => (
<SyntaxHighlighter>
{code}
</SyntaxHighlighter>
),
[code]
);
return (
<div>
{memoizedHighlighter}
</div>
); |
Describe the bug
Any time React does a re-render on the
SyntaxHighlighter
component, the component does a full re-parse, re-highlight of the entire document even when the document hasn't changed. The most egregious offender isgetCodeTree
and next up isprocessLines
.I think the fix here is to simply wrap these in
useMemo
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Video: https://youtu.be/N01PEn3BZIk
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: