Skip to content

Commit

Permalink
fix: Fix value issue. (#162 #161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 20, 2022
1 parent 3d2b3ed commit 3d26f6d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function MonacoEditor(props: MonacoEditorProps, ref: ((instance: RefEditorInstan
const container = useRef<HTMLDivElement>(null);
const editor = useRef<monaco.editor.IStandaloneCodeEditor>();
useImperativeHandle(ref, () => ({ container: container.current, editor: editor.current, monaco }));
useEffect(() => setVal(value), [value])
useEffect(() => {
if (editor.current) {
editor.current.setValue(val);
}
}, [val])
useEffect(() => {
if (container.current) {
editor.current = monaco.editor.create(container.current, {
Expand Down

0 comments on commit 3d26f6d

Please sign in to comment.