Concepts
OverviewCompositionTestingLayout
Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrapComponents
AccordionAdmonitionAvatarButtonCheckboxComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsProgressPrompt ModalRadioRatingSelectSwitchTableTabsTagTextTextareaToggleTooltipUtilities
Feature FlagsForLocal StoragePortalShowsplitPropsTheme1import { getLocalStorage, setLocalStorage } from '@cerberus/react'
Usage
1'use client';2
3import { getLocalStorage } from '@cerberus/react'4import { useState } from 'react'5
6export default function Page() {7 const [value, setValue] = useState<string>('')8
9 // You have to wait until the component is mounted to10 // have access to the local storage11 useEffect(() => {12 const value = getLocalStorage('key')13 setValue(value)14 }, [])15
16 return (17 <Text>18 This is from local storage: {value}19 </Text>20 )21}
API
getLocalStorage
Name | Default | Description |
---|---|---|
key | The key that the value is saved under | |
defaultValue | The default value to return if the key does not exist in localStorage |
setLocalStorage
Name | Default | Description |
---|---|---|
key | The key to save the value under | |
value | The value to save in localStorage |
On this page