useEffect(() => {
let stopGettingAfterUnmount = false;
const getTodo = async () => {
await axios
.get("/api/todo", {
headers: {
"Content-Type": "application/json",
},
params: { userId },
})
.then((response) => {
if (stopGettingAfterUnmount) return;
setTodos(response.data);
});
};
getTodo();
return () => {
stopGettingAfterUnmount = true;
};
}, [userId]);
const copyArray = (array = []) => JSON.parse(JSON.stringify(array));
const [contacts, setContacts] = useState(copyArray(data));
const [contactsInput, setContactsInput] = useState(copyArray(data));
const getSpecificImage = (breakpoint) => {
switch (breakpoint) {
case 1200:
return <Image src="https://google.com?v=1200" />;
case 600:
return <Image src="https://google.com?v=600" />;
default:
return <Image src="https://google.com?v=default" />;
}
};
const breakpoint = window?.innerWidth;
const imageElement = getImageSpecificImage(breakpoint);
return (
<>
{imageElement}
</>
);
const TaskRegionView = () => {
const isMenuOpenLocalStorageKey = '__isMenuOpen';
const [condition, setCondition] = useState(() => {
const value = localStorage.getItem(isMenuOpenLocalStorageKey);
const isOpen = JSON.parse(value);
if (isOpen === null) return false;
return value;
});
const handleToggleCondition = () => {
setCondition((prev) => {
const state = !prev;
localStorage.setItem(isMenuOpenLocalStorageKey, JSON.stringify(state));
return state;
});
};
...
Buffer.from('your img buffer').toString('base64')