react-fetching-library

Simple and powerful API client for react 👍 Use hooks or FACCs to fetch data in easy way. No dependencies! Just react under the hood.

Github星跟踪图

Watch on GitHubStar on GitHubTweet


Build Status version downloads MIT License
PRs Welcome Code of Conduct Code of Conduct codecov

✅ Zero dependencies (react, react-dom as peer deps)

✅ SSR support

✅ Use hooks or FACC's (Function as Child Components) - depending on your needs

✅ Uses Fetch API (but allows to use custom fetch implemenation and axios as well)

✅ Request and response interceptors allows to easily customize connection with API

✅ React Suspense support (experimental *)

✅ TypeScript support

✅ Error boundaries to catch bad API responses

✅ Less than 3k minizipped

✅ Simple cache provider - easily to extend

✅ Handle race conditions

✅ Allows to abort pending requests


react-fetching-library

Use hooks or FACC's (Function as Child Component) to fetch data in an easy way. No dependencies! Just React under the hood.

Request and response interceptors allows you to easily customize connection with API (add authorization, refresh token, cache, etc). It uses Fetch API so it can be used in SSR apps (i.e. with isomorphic-fetch).

Library allows you to use it with connection of React Suspense (read more about React Suspense) to easily maintain loading state in application.

Documentation

Full documentation is available HERE

Short example of use

import { useQuery } from 'react-fetching-library';

const fetchUsersList = {
  method: 'GET',
  endpoint: '/users',
};

export const UsersListContainer = () => {
  const { loading, payload, error, query } = useQuery(fetchUsersList);

  return <UsersList loading={loading} error={error} users={payload} onReload={query} />;
};

Edit Basic Example

Typescript support

Inspirations

Contributing

Feel free to open PRs and issues to make this library better !

When making a PR, make sure all tests pass. If you add a new feature, please consider updating the documentation or codesandbox examples. Thank you!

Using Suspense to fetch data

For now React Suspense is not production ready to use it for fetch data as described here, so API of our component/hook may change in the future.

License

react-fetching-library is licensed under the MIT license.

主要指标

概览
名称与所有者marcin-piela/react-fetching-library
主编程语言TypeScript
编程语言TypeScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2019-03-11 20:18:42
推送于2023-01-04 09:50:09
最后一次提交2021-02-22 08:41:00
发布数45
最新版本名称1.7.6 (发布于 )
第一版名称0.0.1-beta.0 (发布于 )
用户参与
星数623
关注者数9
派生数34
提交数206
已启用问题?
问题数54
打开的问题数16
拉请求数45
打开的拉请求数49
关闭的拉请求数27
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?