Skip to content

Latest commit

 

History

History
345 lines (189 loc) · 11.6 KB

CHANGELOG.md

File metadata and controls

345 lines (189 loc) · 11.6 KB

6.6.0 (2024-03-10)

Features

  • useRequest: getResponseItem option (#22)

6.5.0 (2023-10-21)

Features

  • request: export _request to custom response type (#21)

6.4.2 (2023-05-04)

Features

  • refactor(cache-key): replace with object-code to generate cache key. (#20)

6.4.1 (2023-04-23)

Bug Fixes

  • type: onCompleted response generic error. (aed68bf)

6.4.0 (2023-03-26)

Bug Fixes

  • createRequestError: value num 0. (84a3084)

Features

  • cache: use ttl cache by default. (#19)

  • onCompleted types: parameters is required. (96f1f8d)

  • CData type: replace CData width BodyData. (5f26f42)

    No BREAKING CHANGES. Will keep CData type, but deprecated.

6.3.0 (2022-12-05)

Bug Fixes

  • useResource: catch fnOptions undefined error. (bd74a59)

Chore

  • Upgrade devDependencies. (axios v1 #17)

6.2.0 (2022-08-23)

Bug Fixes

  • types: ready return type (RequestFactory). (1407056)

Features

  • useResource: return refresh func. (f6e7692)
    - const [reqState, fetch] = useResource();
    + const [reqState, fetch, refresh] = useResource();

6.1.0 (2022-07-05)

Features

  • 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)

BREAKING CHANGES

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

Features

  • 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)

Chore

5.1.0 (2022-02-13)

Features

  • RequestProvider: RequestProvider is optional. You can use useRequest, useResource directly. (afd0e40)

5.0.1 (2021-12-16)

Chore

  • peerDependencies: axios version >= 0.21.4. (for AxiosRequestConfig genericity ) (fe6ac4e)

5.0.0 (2021-12-08)

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 (2021-11-24)

Features

  • Type: keep AxiosRequestConfig generics. (#4)

4.2.0 (2021-10-15)

Bug Fixes

  • Unsafe argument of type. (f41e627)

Building

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

Chore

4.1.0 (2021-08-23)

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>

Chore

4.0.0 (2021-06-02)

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 (2021-01-03)

Features (BREAKING CHANGES)

  • 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)

Building

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

2.2.1 (2020-12-25)

Building

  • Not allow Synthetic Default Imports. (for fast-deep-equal) (645d2c2)

2.2.0 (2020-12-24)

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)