Skip to content

Commit

Permalink
fix(react-codemirror): unexpected effect called when extension is null (
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec committed Jul 21, 2023
1 parent 528759f commit bed5e80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/useCodeMirror.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { Annotation, EditorState, StateEffect } from '@codemirror/state';
import { Annotation, EditorState, StateEffect, type Extension } from '@codemirror/state';
import { EditorView, ViewUpdate } from '@codemirror/view';
import { getDefaultExtensions } from './getDefaultExtensions';
import { getStatistics } from './utils';
Expand All @@ -11,6 +11,8 @@ export interface UseCodeMirror extends ReactCodeMirrorProps {
container?: HTMLDivElement | null;
}

const emptyExtensions: Extension[] = [];

export function useCodeMirror(props: UseCodeMirror) {
const {
value,
Expand All @@ -19,7 +21,7 @@ export function useCodeMirror(props: UseCodeMirror) {
onStatistics,
onCreateEditor,
onUpdate,
extensions = [],
extensions = emptyExtensions,
autoFocus,
theme = 'light',
height = '',
Expand Down

0 comments on commit bed5e80

Please sign in to comment.