dan
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
5 deletions
-
beta/src/components/MDX/Sandpack/Preview.tsx
|
@ -61,16 +61,23 @@ export function Preview({ |
|
|
rawError = null; |
|
|
rawError = null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (lintErrors.length > 0) { |
|
|
// Memoized because it's fed to debouncing.
|
|
|
if (rawError == null || rawError.title === 'Runtime Exception') { |
|
|
const firstLintError = React.useMemo(() => { |
|
|
// When there's a lint error, show it -- even over a runtime error.
|
|
|
if (lintErrors.length === 0) { |
|
|
// (However, when there's a build error, we keep showing the build one.)
|
|
|
return null; |
|
|
|
|
|
} else { |
|
|
const {line, column, message} = lintErrors[0]; |
|
|
const {line, column, message} = lintErrors[0]; |
|
|
rawError = { |
|
|
return { |
|
|
title: 'Lint Error', |
|
|
title: 'Lint Error', |
|
|
message: `${line}:${column} - ${message}`, |
|
|
message: `${line}:${column} - ${message}`, |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
}, [lintErrors]); |
|
|
|
|
|
|
|
|
|
|
|
if (rawError == null || rawError.title === 'Runtime Exception') { |
|
|
|
|
|
if (firstLintError !== null) { |
|
|
|
|
|
rawError = firstLintError; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// It changes too fast, causing flicker.
|
|
|
// It changes too fast, causing flicker.
|
|
|