File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
beta/src/components/MDX/Sandpack Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -61,16 +61,23 @@ export function Preview({
6161 rawError = null ;
6262 }
6363
64- if ( lintErrors . length > 0 ) {
65- if ( rawError == null || rawError . title === 'Runtime Exception' ) {
66- // When there's a lint error, show it -- even over a runtime error.
67- // (However, when there's a build error, we keep showing the build one.)
64+ // Memoized because it's fed to debouncing.
65+ const firstLintError = React . useMemo ( ( ) => {
66+ if ( lintErrors . length === 0 ) {
67+ return null ;
68+ } else {
6869 const { line, column, message} = lintErrors [ 0 ] ;
69- rawError = {
70+ return {
7071 title : 'Lint Error' ,
7172 message : `${ line } :${ column } - ${ message } ` ,
7273 } ;
7374 }
75+ } , [ lintErrors ] ) ;
76+
77+ if ( rawError == null || rawError . title === 'Runtime Exception' ) {
78+ if ( firstLintError !== null ) {
79+ rawError = firstLintError ;
80+ }
7481 }
7582
7683 // It changes too fast, causing flicker.
You can’t perform that action at this time.
0 commit comments