Coder Social home page Coder Social logo

bionaut / react-fetching-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcin-piela/react-fetching-library

0.0 1.0 0.0 6.43 MB

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

License: MIT License

TypeScript 98.39% JavaScript 1.61%

react-fetching-library's 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.

react-fetching-library's People

Contributors

dependabot[bot] avatar dugagjin avatar gamtiq avatar il-rvankints avatar josejulio avatar marcin-piela avatar mattrothenberg avatar sjiep avatar szarlus avatar tylerrick avatar xr4in3 avatar youknowriad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.