You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React Syntax Highlighter allows for the use of custom renderers to change the behavior of the way the syntax highlighted code is rendered. This module utilizes React Virtualized to virtualize rendering of non visible code nodes to allow for better performance when syntax highlighting large blocks. See an example: here
importSyntaxHighlighterfrom'react-syntax-highlighter';importvirtualizedRendererfrom'react-syntax-highlighter-virtualized-renderer';import{docco}from'react-syntax-highlighter/styles/hljs';constComponent=()=>{constcodeString='(num) => num + 1';return(<SyntaxHighlighterlanguage='javascript'style={docco}renderer={virtualizedRenderer()}>{codeString}</SyntaxHighlighter>);}
Optional Options Argument
overscanRowCount - number of rows to render ahead of what is currently visible. (defaults to 10)
rowHeight - if you use different fonts / line height styles, you made need to adjust the row height (defaults to 15)
About
a way to use react-virtualized to render lines of code for react-syntax-highlighter