This is a roadmap of future features in consideration for use-axios-client
, along with some rough API designs.
Provide an optional cachePolicy
field on hooks to allow consumers to selectively optimize network requests. This entry can be keyed by something like url
+ stringified data
.
We can persist the cache to a singleton that all hooks can read/write from.
Always fire network call for data
(default):
const { data, error, loading } = useAxios({
url: 'https://example/api',
cachePolicy: 'no-cache',
});
Pull data
from in-memory cache if it exists, otherwise fire network call:
const { data, error, loading } = useAxios({
url: 'https://example/api',
cachePolicy: 'in-memory',
});
Pull data
from in-memory cache if it exists, then fire network call:
const { data, error, loading } = useAxios({
url: 'https://example/api',
cachePolicy: 'in-memory-first',
});
Persist and pull data
from local storage:
const { data, error, loading } = useAxios({
url: 'https://example/api',
cachePolicy: 'localStorage',
});
Persist and pull data
from session storage:
const { data, error, loading } = useAxios({
url: 'https://example/api',
cachePolicy: 'sessionStorage',
});
See initial draft PR.
import { useAxios } from 'use-axios-client';
const Child = () => {
const { data } = useAxios({
url: 'https://example/api',
suspense: true,
});
return <div>{data}</div>;
};
const Parent = () => (
<React.Suspense fallback="Loading...">
<Child />
</React.Suspense>
);