I'm trying to load cookie into useState. It is a simple open/closed state for a drawer made in MUI. However, with my solution it is always closed on reload and I get hydration error. The same happens when i try to do it with localStorage. I did what hydration error said I should do but it didn't help.
`const [open, setOpen] = useState(() => {
return !!(getCookie('open'))
})
const toggleDrawer = () => {
setCookie('open', !open)
setOpen(!open);
}
useEffect(() => {
const openCookie = getCookie('open')
setOpen(!!(openCookie))
},[])`