• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

marcin-piela/react-fetching-library: Simple and powerful API client for react ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

marcin-piela/react-fetching-library

开源软件地址(OpenSource Url):

https://github.com/marcin-piela/react-fetching-library

开源编程语言(OpenSource Language):

TypeScript 98.4%

开源软件介绍(OpenSource Introduction):

Simple and powerful fetching library for React. Use hooks to fetch data!

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap