Releases: axios-use/axios-use-react
Releases · axios-use/axios-use-react
5.0.0
Features
- RequestContext:
customCreateReqError
function. (#5) - useResource:
defaultState
options. (4cc6643) - useRequest/useResource:
onCompleted
,onError
options. (#6)// useRequest const [createRequest, { hasPending, cancel }] = useRequest( (id) => ({ url: `/user/${id}`, method: "DELETE" }), { onCompleted: (data, other) => console.info(data, other), onError: (err) => console.info(err), }, ); // useResource const [{ data, isLoading, error }] = useResource( () => ({ url: "/users/", method: "GET" }), [], { onCompleted: (data, other) => console.info(data, other), onError: (err) => console.info(err), }, );
Bug Fixes
- useResource: default isLoading value when using filter (state). (4fb4f6d)
4.3.0
4.2.0
4.1.0
4.0.0
Features
- useResource: Use cache initialization state (#2)
- context: separate the values of provider(props) (35ea8a2)
- <RequestProvider value={axiosInstance}> + <RequestProvider instance={axiosInstance}> <App /> </RequestProvider>,
- type: split with RequestContextConfig (null) (fd91fcb)
export type RequestContextConfig<T = any> = { instance?: AxiosInstance; cache?: Cache<T> | false; cacheKey?: CacheKeyFn<T>; cacheFilter?: CacheFilter<T>; }; export type RequestContextValue<T = any> = RequestContextConfig<T> | null;
3.0.0
Features
- useRequest: swap returns (7169e9e)
// before const [request, createRequest] = useRequest(...); // now const [createRequest, request] = useRequest(...);
- return other responses (3924e0c)
const [createRequest] = useRequest(...); const fetch = async () => { // before const response = await createRequest.ready(); // now. [T, Omit<AxiosResponse<T>, "data">] const [response, otherAxiosReponse] = await createRequest.ready(); }
// before const [{ data, error, isLoading, cancel }] = useResource(...); // now. other: Omit<AxiosResponse, "data"> const [{ data, other, error, isLoading, cancel }] = useResource(...);