I have an error like this:
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. at ToDoAdder (http://localhost:3000/static/js/main.chunk.js:193:3)
here's my code:
import React, { useState } from 'react';
import { useEffect } from 'react';
import { Trash, Pen, CheckLg, XCircleFill } from 'react-bootstrap-icons';
import { Button } from 'react-bootstrap';
import store from '../../store';
function ToDoAdder({ data }) {
const [user, setUser] = useState({});
const { id, title, completed, userId } = data;
useEffect(() => {
fetchUsers();
}, [user]);
const fetchUsers = async () => {
const data = await fetch(
`https://jsonplaceholder.typicode.com/users/${userId}`
);
const users = await data.json();
setUser(users);
return user;
};
const handleTodoRemove = () => {
console.log(id);
store.dispatch({ type: 'remove/todo', payload: { id } });
};
return (
// here goes some code
)
}
export default ToDoAdder;
Please help me to fix this problem