DEV Community

Discussion on: Practical data fetching with React Suspense that you can use today

Collapse
 
andreiduca profile image
Andrei

Calling fetch immediately will start the api call immediately. But data needs to be retrieved on demand, and usually with parameters (fetch a user by its id). You cannot create fetch promises for all possible IDs you don't know you're going to use.

Also, we're not caching the fetch requests (i.e. the functions that return the promises), but the generated data reader functions (i.e. the functions that just return the data, or throw the in-progress promises).