fix: fixed the loading issue by adding a suspense (#510)
This commit is contained in:
parent
4630426ae7
commit
5bbb59d5dc
@ -35,18 +35,21 @@ export default function useLocalStorage<T>(key: string, defaultValue: T): [T, (v
|
|||||||
}
|
}
|
||||||
}, [updateValue])
|
}, [updateValue])
|
||||||
|
|
||||||
const setValue = useCallback((value: T) => {
|
const setValue = useCallback(
|
||||||
try {
|
(value: T) => {
|
||||||
updateValue(value)
|
try {
|
||||||
|
updateValue(value)
|
||||||
|
|
||||||
localStorage.setItem(keyRef.current, JSON.stringify(value))
|
localStorage.setItem(keyRef.current, JSON.stringify(value))
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.dispatchEvent(new StorageEvent('storage', { key: keyRef.current }))
|
window.dispatchEvent(new StorageEvent('storage', { key: keyRef.current }))
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
},
|
||||||
console.error(e)
|
[updateValue],
|
||||||
}
|
)
|
||||||
}, [])
|
|
||||||
|
|
||||||
return [value, setValue]
|
return [value, setValue]
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import { isMobile } from 'react-device-detect'
|
import { isMobile } from 'react-device-detect'
|
||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
|
import { Suspense } from 'react'
|
||||||
|
|
||||||
import AccountDetails from 'components/Account/AccountDetails'
|
import AccountDetails from 'components/Account/AccountDetails'
|
||||||
import Background from 'components/Background'
|
import Background from 'components/Background'
|
||||||
import Footer from 'components/Footer'
|
import Footer from 'components/Footer'
|
||||||
import DesktopHeader from 'components/Header/DesktopHeader'
|
import DesktopHeader from 'components/Header/DesktopHeader'
|
||||||
import MigrationBanner from 'components/MigrationBanner'
|
|
||||||
import ModalsContainer from 'components/Modals/ModalsContainer'
|
import ModalsContainer from 'components/Modals/ModalsContainer'
|
||||||
import PageMetadata from 'components/PageMetadata'
|
import PageMetadata from 'components/PageMetadata'
|
||||||
import Toaster from 'components/Toaster'
|
import Toaster from 'components/Toaster'
|
||||||
@ -65,10 +65,11 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|||||||
isMobile && 'items-start',
|
isMobile && 'items-start',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<PageContainer focusComponent={focusComponent} fullWidth={isFullWidth}>
|
<Suspense>
|
||||||
{children}
|
<PageContainer focusComponent={focusComponent} fullWidth={isFullWidth}>
|
||||||
</PageContainer>
|
{children}
|
||||||
|
</PageContainer>
|
||||||
|
</Suspense>
|
||||||
<AccountDetails />
|
<AccountDetails />
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
Loading…
Reference in New Issue
Block a user