Skip to content

Commit

Permalink
Merge pull request #8 from MOV-AI/improvement/update-code-on-change-prop
Browse files Browse the repository at this point in the history
Update editor code on change value prop
  • Loading branch information
RianMartins-Movai authored Dec 10, 2021
2 parents c60d1c1 + b535ad3 commit cf91330
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/MonacoCodeEditor/MonacoCodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ const MonacoCodeEditor = React.forwardRef((props, ref) => {
editor.current = _editor;
}, []);

/**
* On change Code
*/
React.useEffect(() => {
const currentValue = editor.current?.getValue();
if (editor.current && currentValue !== value) {
editor.current.setValue(value);
}
}, [value]);

/**
* On change Theme
*/
Expand Down

0 comments on commit cf91330

Please sign in to comment.