RTK Query Loader tries to give you all the flexibility you need to create reusable and extendable loaders.
- Supply as many queries as you'd like.
- Supply queries that don't affect loading state.
- Send down payloads that contain any static data.
- Transform the data to your desired output-format.
- Set up default loading and error states.
- Extend and re-use existing loaders.
- Create stateful loaders
And even if you don't use
You can extend existing Loaders. This lets you inherit and overwrite properties from an existing Loader.
You can transform the queries to any format you'd like.
📄️ Deferring queries
Say you have a query that takes a long time to resolve. You want to put it in the loader, to co-locate it with the rest of your queries, but you don't want it to affect the loading state and postpone the initial load of the component. This is where deferredQueries comes in.
📄️ Use with other libraries
You can use RTK Query Loader with most other similar query-fetching libraries. This is possible through the use of resolvers.
📄️ Custom loaderComponent
A loaderComponent is the component that determines what to render given the aggregated query status, when using withLoader.
📄️ Passing arguments
You can setup loaders so that they can be used with arguments. How you pass the arguments depends on how you use the loader.
📄️ Stateful loaders
Since a Loader contains a hook, that hook can contain state.