6.6.0 (2024-03-10)
- useRequest:
getResponseItem
option (#22)
6.5.0 (2023-10-21)
- request: export
_request
to custom response type (#21)
6.4.2 (2023-05-04)
- refactor(cache-key): replace with
object-code
to generate cache key. (#20)
6.4.1 (2023-04-23)
- type:
onCompleted
response generic error. (aed68bf)
6.4.0 (2023-03-26)
- createRequestError: value num 0. (84a3084)
-
cache: use ttl cache by default. (#19)
-
onCompleted types: parameters is required. (96f1f8d)
-
CData type: replace
CData
widthBodyData
. (5f26f42)No BREAKING CHANGES. Will keep
CData
type, but deprecated.
6.3.0 (2022-12-05)
- useResource: catch
fnOptions
undefined error. (bd74a59)
- Upgrade devDependencies. (axios v1 #17)
6.2.0 (2022-08-23)
- types: ready return type (RequestFactory). (1407056)
- useResource: return refresh func. (f6e7692)
- const [reqState, fetch] = useResource(); + const [reqState, fetch, refresh] = useResource();
6.1.0 (2022-07-05)
-
feat(useRequest): return all response. (e9317ce)
interface CreateRequest { // Promise function - ready: () => Promise<[Payload<TRequest>, AxiosRestResponse]>; + ready: () => Promise<[Payload<TRequest>, AxiosResponse]>; // Axios Canceler. clear current request. cancel: Canceler; }
- const [{ data, error, isLoading, other }] = useResource(...) + const [{ data, error, isLoading, response }] = useResource(...)
No BREAKING CHANGES. Will keep other
value, but deprecated.
6.0.0 (2022-05-15)
You must update all imports from '@react-cmpt/react-request-hook' to '@axios-use/react'
🚨🚨🚨 Find/replace @react-cmpt/react-request-hook
for @axios-use/react
and upgrade to v6
- Customize the Axios instance of the current item. (#10)
const customIns = axios.create({ // ... }); function Profile({ userId }) { const [{ data, error, isLoading }] = useResource( (id) => ({ url: `/user/${id}` }), [userId], { instance: customIns }, ); // ... }
- useResource: requestParams type can be
false
. (887aabc)
5.1.0 (2022-02-13)
- RequestProvider:
RequestProvider
is optional. You can useuseRequest
,useResource
directly. (afd0e40)
5.0.1 (2021-12-16)
- peerDependencies: axios version >= 0.21.4. (for
AxiosRequestConfig
genericity ) (fe6ac4e)
5.0.0 (2021-12-08)
- 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), }, );
- useResource: default isLoading value when using filter (state). (4fb4f6d)
4.3.0 (2021-11-24)
- Type: keep AxiosRequestConfig generics. (#4)
4.2.0 (2021-10-15)
- Unsafe argument of type. (f41e627)
- Support react version < 17. tsconfig.compilerOptions.jsx
react-jsx
->react
. (60a762e)
4.1.0 (2021-08-23)
- useResource: options
filter
. if return a falsy value, will not start the request. (#3)filter?: (...args: Parameters<T>) => boolean;
- UseResourceOptions genericity (b2b0501)
- UseResourceOptions<Payload<TRequest>> + UseResourceOptions<TRequest>
4.0.0 (2021-06-02)
- 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 (2021-01-03)
- 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(...);
2.2.2 (2020-12-27)
- To ensure compatibility in the emitted JavaScript. (
esModuleInterop
,allowSyntheticDefault
) (for dependencies) (b62273f)
2.2.1 (2020-12-25)
- Not allow Synthetic Default Imports. (for
fast-deep-equal
) (645d2c2)