Make sure the code-init is robust when local storage is empty

Plus fix local storage for old code
This commit is contained in:
Kurt Hutten
2021-05-30 13:43:56 +10:00
parent d7aaeda187
commit bd7aa4cc4e
4 changed files with 14 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { useContext, Suspense, lazy } from 'react'
import { IdeContext } from 'src/components/IdeToolbarNew'
import { codeStorageKey } from 'src/helpers/hooks/useIdeState'
import { makeCodeStoreKey } from 'src/helpers/hooks/useIdeState'
import { requestRender } from 'src/helpers/hooks/useIdeState'
const Editor = lazy(() => import('@monaco-editor/react'))
@@ -38,7 +38,7 @@ const IdeEditor = () => {
camera: state.camera,
})
})
localStorage.setItem(codeStorageKey, state.code)
localStorage.setItem(makeCodeStoreKey(state.ideType), state.code)
}
}
const loading = (