Skip to content

Commit

Permalink
Allow editor to make text updates with state
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Segreto committed Jun 14, 2021
1 parent b37fd8b commit 21cb9e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ export const Container = styled.div`

function OurEditor() {
const monaco = useMonaco();
const [editorCode, setEditorCode] = useState("// def");

useEffect(() => {
if (monaco) {
registerMotoko(monaco);
}
}, [monaco]);

const onEditorChange = (newValue, ev) => {
ev.preventDefault();
setEditorCode(newValue);
}

return (
<Container>
<Editor
height="90vh"
defaultLanguage="motoko"
defaultValue="// some comment"
value={editorCode}
onChange={onEditorChange}
/>
</Container>
)
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noImplicitAny": false,
"noEmit": true,
"jsx": "react-jsx"
},
Expand Down

0 comments on commit 21cb9e5

Please sign in to comment.