Closed s1n7ax closed 3 months ago
You already execute the axios request in your fetchData()
request, which is too early.
const fetchData = () => {
return wrapPromise(axios.get('/test').then((r) => r.data));
};
const resource = fetchData();
Not sure how you should structure the code with suspense, but you should delay the fetching until the component is initialized (maybe in a mounted hook or something similar)
I have a component that waits until some data from a resource. I'm using React suspense to show the loading screen as until it gets the response. When testing, even though
onGet
is registered, inaxiosMock
, it never gets the request from<Cmp />
component. Test fails due to network error.Example code: