I am getting this error:
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. 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 Products (http://localhost:3000/static/js/main.chunk.js:2779:5) at div at Home at RenderedRoute (http://localhost:3000/static/js/vendors~main.chunk.js:246119:5) at Routes (http://localhost:3000/static/js/vendors~main.chunk.js:246568:5) at Router (http://localhost:3000/static/js/vendors~main.chunk.js:246499:15) at BrowserRouter (http://localhost:3000/static/js/vendors~main.chunk.js:244709:5) at div at App
I assume the problem is here:
Products.js
const [products, setProducts] = useState([]);
useEffect(() => {
const getProdcuts = async () => {
try {
const res = await axios.get(
category
? `http://localhost:5000/e-mart/products?category=${category}`
: `http://localhost:5000/e-mart/products`
);
setProducts(res.data);
} catch (err) {
console.log(err.message);
}
};
getProdcuts();
}, [category]);
My home page is not loading. No problem is shown in the terminal. How can I resolve this?