Facebook Pixel

How do I fix the 'state update on unmounted component' warning?

Use a cleanup flag that tracks whether the component is still mounted, or an AbortController to cancel the fetch on unmount. Only update state if the component is still mounted.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Common Swiggy API Errors in React Projects and How to Resolve Them

Use a development proxy in your bundler config or a small backend proxy. The proxy forwards the request server-side, bypassing the browser's CORS restrictions for local development.

Because your code expects an array but the response is an object with the array nested inside. Log the full response, find the array in the correct field, and update your parsing to extract it before calling map.

It means you are calling the API too often and are being rate-limited. Cache responses so you do not re-request the same data, and reduce the frequency of your calls.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.