Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Add localstorage to frontend #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add localstorage to frontend #25

wants to merge 4 commits into from

Conversation

Kazan1520
Copy link
Contributor

so the code doesn't disappear after clicking "submit" without being authorized

@@ -21,8 +21,9 @@ const CodeEditor = ({ authToken }: CodeEditorProps) => {
const [monacoInstance, setMonacoInstance] = useState<Monaco | null>(null);
const [output, setOutput] = useState<{ stdOut: string; stdErr: string; exitCode: number } | null>(null);
const [error, setError] = useState<{ message: string } | null>(null);

const [currentText] = useState(typeof window !== "undefined" ? localStorage.getItem("code") || '// Write your code here' : "// Write your code here");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since your are not using setCurrentText(), you don't really need useState() to begin with.

Just pass the text you want directly into the defaultValue prop.

@mherda64
Copy link
Collaborator

Please bump the image version

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants