Skip to content

1.6.0

Choose a tag to compare

@marcin-piela marcin-piela released this 20 Feb 20:21
· 37 commits to master since this release
0067edf

Improvements

  • package size reduction (replace tsc with rollup and closure compiler)
  • allow to define response TS type directly in action definition
type UsersResponse = {
    data: User[];
    meta: any;
}

export const fetchUsersList: Action<UsersResponse> = {
  method: 'GET',
  endpoint: '/users',
};

and then you can skip type in component ie.

const { payload } = useQuery(fetchUsersList)

instead of

const { payload } = useQuery<UsersResponse>(fetchUsersList)

Breaking changes

  • MutateContext and QueryContext have been removed - it's easier to create own context in application
  • First parameter for Action type is now response type, to extend base Action (ie. to add some new params) you have to create type like that:
import { Action as BaseAction } from 'react-fetching-library';

export type Action<T = any, K = { skipAuth?: boolean; }> = BaseAction<T, K>;