Skip to content

Releases: axios-use/axios-use-react

5.0.0

08 Dec 03:06
Compare
Choose a tag to compare

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

24 Nov 13:22
Compare
Choose a tag to compare

Features

  • Type: keep AxiosRequestConfig generics. (#4)

4.2.0

15 Oct 02:11
Compare
Choose a tag to compare

Bug Fixes

  • Unsafe argument of type. (f41e627)

Building

  • Support react version < 17. tsconfig.compilerOptions.jsx react-jsx -> react. (60a762e)

Chore

4.1.0

23 Aug 06:20
Compare
Choose a tag to compare

Features

  • 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

09 Jun 02:33
Compare
Choose a tag to compare

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

03 Jan 09:04
Compare
Choose a tag to compare

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(...);

2.2.2

27 Dec 07:27
Compare
Choose a tag to compare

Building

  • To ensure compatibility in the emitted JavaScript. (esModuleInterop, allowSyntheticDefault) (for dependencies) (b62273f)

2.2.0

24 Dec 04:08
Compare
Choose a tag to compare

Bug Fixes

  • useResource: canceller closure (f0d63ef)
  • block state update on uninstall (a7242b9)

Features

  • return original error (eedcc72)
  • useResource: add res type and useDeepMemo (d56da08)
  • utils: useDeepMemo (c7af8cd)
  • utils: useMountedState hook (0596a63)
  • deps: upgrade axios -> ^0.19 (cdc899f)