Merge pull request #25093 from overleaf/td-upgrade-react-error-boundary-second-attempt

Upgrade react-error-boundary to version 5, second attempt

GitOrigin-RevId: 2b88334b66f0ace383211c147279ff88e9f956bb
This commit is contained in:
Tim Down
2025-04-29 08:06:23 +00:00
committed by Copybot
parent d7bd665bee
commit 5d78229e1e
17 changed files with 150 additions and 106 deletions
@@ -16,4 +16,6 @@ function SourceEditor() {
)
}
export default withErrorBoundary(memo(SourceEditor), ErrorBoundaryFallback)
export default withErrorBoundary(memo(SourceEditor), () => (
<ErrorBoundaryFallback />
))
@@ -33,7 +33,7 @@ import { setSpellCheckLanguage } from '../extensions/spelling'
import { setKeybindings } from '../extensions/keybindings'
import { Highlight } from '../../../../../types/highlight'
import { EditorView } from '@codemirror/view'
import { useErrorHandler } from 'react-error-boundary'
import { useErrorBoundary } from 'react-error-boundary'
import { setVisual } from '../extensions/visual/visual'
import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
@@ -265,7 +265,7 @@ function useCodeMirrorScope(view: EditorView) {
visual: showVisual,
})
const handleError = useErrorHandler()
const { showBoundary } = useErrorBoundary()
const handleException = useCallback((exception: any) => {
captureException(exception, {
@@ -304,7 +304,7 @@ function useCodeMirrorScope(view: EditorView) {
spelling: spellingRef.current,
visual: visualRef.current,
projectFeatures: projectFeaturesRef.current,
handleError,
showBoundary,
handleException,
}),
})
@@ -335,7 +335,7 @@ function useCodeMirrorScope(view: EditorView) {
}
// IMPORTANT: This effect must not depend on anything variable apart from currentDocument,
// as the editor state is recreated when the effect runs.
}, [view, currentDocument, handleError, handleException])
}, [view, currentDocument, showBoundary, handleException])
useEffect(() => {
if (openDocName) {