참고 :
https://wnsdufdl.tistory.com/245
https://bobbyhadz.com/blog/react-usestate-conditional-initial-value
정의한 상태(state)가 무한(infinite) setState가 되고 있어, App이 StackOver된 상태
상태(state)를 setState 하고 있는 코드를 찾는다!
if (typeof localStoragePersitValue === 'string') {
setPersist(JSON.parse(localStoragePersitValue) || false);
}
setPersist(JSON.parse(localStoragePersitValue) || false);
let localStoragePersitValue = localStorage.getItem('persist');
const [auth, setAuth] = useState<ContextAuthType['auth']>(ContextInitialValue);
const [persist, setPersist] = useState<ContextAuthType['persist']>(() => {
if (typeof localStoragePersitValue === 'string') {
const InitialLocalStorageValue =
JSON.parse(localStoragePersitValue) || false;
return InitialLocalStorageValue;
}
});
let localStoragePersitValue = localStorage.getItem('persist');
if (typeof localStoragePersitValue === 'string') {
const InitialLocalStorageValue = JSON.parse(localStoragePersitValue) || false;
return InitialLocalStorageValue;
}
if (typeof localStoragePersitValue === 'string') {
setPersist(JSON.parse(localStoragePersitValue) || false);
}
useState<ContextAuthType['persist']>(() => {
if (typeof localStoragePersitValue === 'string') {
const InitialLocalStorageValue =
JSON.parse(localStoragePersitValue) || false;
return InitialLocalStorageValue;
}
});
let localStoragePersitValue = localStorage.getItem('persist');
const [auth, setAuth] = useState<ContextAuthType['auth']>(ContextInitialValue);
const [persist, setPersist] = useState<ContextAuthType['persist']>(() => {
if (typeof localStoragePersitValue === 'string') {
const InitialLocalStorageValue =
JSON.parse(localStoragePersitValue) || false;
return InitialLocalStorageValue;
}
});