In my Hello.jsx component I'm calling an API which could fail. Here a fake API is called loader:
import React, { useEffect } from "react";
export const Hello = () => {
const loader = async () => {
return Promise.reject("API error.");
};
useEffect(() => {
const load = async () => {
await loader();
};
load();
}, []);
return <h1>Hello World!</h1>;
};
Problem is that the ErrorBoundary component (not displayed here) should print a red message but it doesn't. Error is not "catched". If I throw normally, not inside an async function, it shows the red text "Something went wrong!". Any clue?
<div>
<ErrorBoundary>
<Hello />
</ErrorBoundary>
</div>