question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poor performance on re-render

See original GitHub issue

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 is getCodeTree and next up is processLines.

I think the fix here is to simply wrap these in useMemo.

To Reproduce Steps to reproduce the behavior:

  1. Render a large file.
  2. Note that re-renders are still very slow.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots Screen Shot 2020-08-18 at 1 11 27 PM

Video: https://youtu.be/N01PEn3BZIk

Desktop (please complete the following information):

  • OS: macOS 10.15.4
  • Browser Chrome, FireFox

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ygorduraescommented, Jan 21, 2021

I’m having this same problem with large files. I still haven’t found a workaround for this issue.

0reactions
karlhorkycommented, Mar 14, 2022

Thanks @simmerer !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix the slow render before you fix the re-render - Kent C. Dodds
It doesn't matter if 100% of your renders are necessary, if those renders are slow, it will still produce a bad experience for...
Read more >
Should you optimize every re-render? - Kevin Farrugia
Not all re-renders are bad. Not all re-renders are equal. Some re-renders are more CPU intensive than others. You may debug React re-rendering...
Read more >
Improving component's re-render performance | Dimitrios Lytras
It has always been. No point thinking about these pesky re-renders. Our components were slow from the start. Extracting expensive computations.
Read more >
How many re-renders is too many? - Alex Sidorenko
The number of re-renders is a poor performance metric. The long tree of React components that only return JSX can be re-rendered many...
Read more >
Optimizing React performance by preventing unnecessary re ...
Re-rendering React components unnecessarily can slow down your app and make the UI feel unresponsive. This article explains how to update ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found