Skip to content

Commit

Permalink
fix(Editor): solve callbacks not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Uceda committed Dec 4, 2023
1 parent a1f324e commit b721d05
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/code/src/components/Editor/hooks/editor/useEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ export const useEditor: UseEditor = ({
});
onMount?.(editorRef.current, monaco);
}
return () => {
editorRef.current?.dispose();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

React.useEffect(() => {
////////////////////////////////////////////
// Call onChange callback on content change
const { dispose: disposeOnModelChange } =
Expand All @@ -101,7 +107,12 @@ export const useEditor: UseEditor = ({
);
},
);
return () => {
disposeOnModelChange();
};
}, [onChange]);

React.useEffect(() => {
////////////////////////////////////////////
// Call onValidate callback on model markers change
/**
Expand Down Expand Up @@ -132,12 +143,10 @@ export const useEditor: UseEditor = ({
});

return () => {
disposeOnModelChange();
disposeOnMarkersChange();
editorRef.current?.dispose();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [onValidate]);

useUpdateEffect(() => {
////////////////////////////////////////////
Expand Down

0 comments on commit b721d05

Please sign in to comment.