Skip to content

Commit bed5e80

Browse files
authored
fix(react-codemirror): unexpected effect called when extension is null (#542)
1 parent 528759f commit bed5e80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/useCodeMirror.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from 'react';
2-
import { Annotation, EditorState, StateEffect } from '@codemirror/state';
2+
import { Annotation, EditorState, StateEffect, type Extension } from '@codemirror/state';
33
import { EditorView, ViewUpdate } from '@codemirror/view';
44
import { getDefaultExtensions } from './getDefaultExtensions';
55
import { getStatistics } from './utils';
@@ -11,6 +11,8 @@ export interface UseCodeMirror extends ReactCodeMirrorProps {
1111
container?: HTMLDivElement | null;
1212
}
1313

14+
const emptyExtensions: Extension[] = [];
15+
1416
export function useCodeMirror(props: UseCodeMirror) {
1517
const {
1618
value,
@@ -19,7 +21,7 @@ export function useCodeMirror(props: UseCodeMirror) {
1921
onStatistics,
2022
onCreateEditor,
2123
onUpdate,
22-
extensions = [],
24+
extensions = emptyExtensions,
2325
autoFocus,
2426
theme = 'light',
2527
height = '',

0 commit comments

Comments
 (0)