Skip to content

Commit 5eee5f4

Browse files
committedMar 25, 2023
fix: optimizing useCodeMirror rendering issues. (#474)
1 parent 6968faf commit 5eee5f4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎core/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const ReactCodeMirror = forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((pr
113113
} = props;
114114
const editor = useRef<HTMLDivElement>(null);
115115
const { state, view, container } = useCodeMirror({
116-
container: editor.current,
116+
container: editor.current ? editor.current : undefined,
117117
root,
118118
value,
119119
autoFocus,

‎core/src/useCodeMirror.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ReactCodeMirrorProps } from '.';
1010
const External = Annotation.define<boolean>();
1111

1212
export interface UseCodeMirror extends ReactCodeMirrorProps {
13-
container?: HTMLDivElement | null;
13+
container?: HTMLDivElement;
1414
}
1515

1616
export function useCodeMirror(props: UseCodeMirror) {
@@ -147,7 +147,7 @@ export function useCodeMirror(props: UseCodeMirror) {
147147
};
148148
}, [container, state]);
149149

150-
useEffect(() => setContainer(props.container!), [props.container]);
150+
useEffect(() => setContainer(props.container), [props.container]);
151151

152152
useEffect(
153153
() => () => {

0 commit comments

Comments
 (0)
Please sign in to comment.