23
app/web/src/components/IdeWrapper/useRender.ts
Normal file
23
app/web/src/components/IdeWrapper/useRender.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { makeCodeStoreKey } from 'src/helpers/hooks/useIdeState'
|
||||
import { requestRender } from 'src/helpers/hooks/useIdeState'
|
||||
import { useContext } from 'react'
|
||||
import { IdeContext } from 'src/pages/DevIdePage/DevIdePage'
|
||||
|
||||
export const useRender = () => {
|
||||
const { state, thunkDispatch } = useContext(IdeContext)
|
||||
return () => {
|
||||
thunkDispatch((dispatch, getState) => {
|
||||
const state = getState()
|
||||
dispatch({ type: 'setLoading' })
|
||||
requestRender({
|
||||
state,
|
||||
dispatch,
|
||||
code: state.code,
|
||||
viewerSize: state.viewerSize,
|
||||
camera: state.camera,
|
||||
})
|
||||
})
|
||||
localStorage.setItem(makeCodeStoreKey(state.ideType), state.code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user