-
-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
I believe this is by design, but can you elaborate why the value is only available on the 2nd render, which is triggered by use-local-storage-state itself?
import { useState, useRef } from 'react'
import useLocalStorageState from 'use-local-storage-state'
const App = ({ Component, pageProps }) => {
const [triggerRender, setTriggerRender] = useState('a')
const renderCounter = useRef(0)
renderCounter.current = renderCounter.current + 1
const [test, setTest] = useLocalStorageState('test', {
defaultValue: 'DEFAULT',
})
console.log('cycle:' + renderCounter.current)
console.log('test value:' + test)
return (
<a onClick={() => setTest('TEST')}>set Localstorage state</a>
)
}
export default App
pitkes22 and ryan-williams
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested