Untitled
Anonymous
tsx
03/19/2023 8:42 PM
608 B
17
Indexable
useEffect(() => {
setTimeout(() => {
const item = localStorage.getItem(key);
if (item) {
try {
const decryptState = CryptoJS.AES.decrypt(item, protectKey).toString(
CryptoJS.enc.Utf8,
);
setState(JSON.parse(decryptState));
} catch {
localStorage.removeItem(key);
}
} else {
setState(initialValue);
}
}, 10);
}, [asPath, initialValue]);Editor is loading...