index.js:1 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Вот все мои useEfect
const getUser = () => {
axios.get('http://localhost:3001/users').then(({ data }) => {
data.map(data => {
if(data.authorized){
setStatus(data.authorized);
setUser(data);
}
return data;
});
});
}
const updateList = () => {
axios.get('http://localhost:3001/lists?_expand=color&_embed=tasks').then(({ data }) => {
if(user){
const lists = data.filter(l => l.userId === user.id);
setLists(lists);
}
});
}
useEffect (() => {
axios.get('http://localhost:3001/colors').then(({ data }) => {
setColor(data);
});
getUser();
}, [status, history.location.pathname])
useEffect(() => {
if(Array.isArray(colors)){
selectColor(colors[0].id);
}
updateList();
}, [colors, user])
useEffect(() => {
const listId = history.location.pathname.split('lists/')[1];
if (lists.length > 1) {
const list = lists.find(list => list.id === Number(listId));
setActiveItem(list);
}
}, [lists, history.location.pathname])
Вот AddForm
const addTask = () => {
const obj = {
"listId": list.id,
"text": inputValue,
"completed": false,
"id": Math.random()
};
axios.post('http://localhost:3001/tasks', obj).then(({ data }) => {
onAddTask(list.id, obj);
setShowForm(false);
})
.catch(e => {
alert('Ошибка при добавлении задачи!');
})
}