• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A React hook for resolving promises with Suspense support. <1kb bundle.

usePromise

React hook for resolving promises with Suspense support.

Inspired by fetch-suspense, but this one is not limited to fetch, usePromise works with any Promise.

version minified size minzipped size downloads

Install

  • npm install react-promise-suspense --save

Example

import usePromise from 'react-promise-suspense';

const fetchJson = input => fetch(input).then(res => res.json());

const MyFetchingComponent = () => {
  // usePromise(Promise, [inputs,],)
  const data = usePromise(fetchJson, [
    'https://pokeapi.co/api/v2/pokemon/ditto/',
    { method: 'GET' },
  ]);

  return <pre>{JSON.stringify(data, null, 2)}</pre>;
};

const App = () => {
  return (
    <Suspense fallback="Loading...">
      <MyFetchingComponent />
    </Suspense>
  );
};

More Repositories

1

what_the_thing

πŸ“·β€€Point your camera at things to learn how to say them in a different language. Android app built with React Native.
JavaScript
546
star
2

IPFS-CRDT-shared-editing

Decentralized Real-Time Collaborative Documents - Conflict-free editing in the browser using js-IPFS and CRDTs.
JavaScript
44
star
3

timetable-generator

πŸ“†β€€Beautiful Auto timetable generator. Generates time-tables from a list of Teachers, Classes and Rooms. Single Page App Built With React & Firebase.
JavaScript
21
star
4

ChatUI

A Chatbot UI
CSS
19
star
5

webSocket-notifications

Websockets Notifications example. Node + Socket.io
JavaScript
14
star
6

Into-the-ReactJs

πŸš€ Code samples for my 'Getting started and advancing with ReactJs' Workshop at Facebook Dev Circle.
JavaScript
10
star
7

Lyricaly

🎡 Lyricaly gets Lyrics delivered to your Terminal for any Song. Uses Python beautifulsoup4 to scrap lyrics. pypi: lyricaly
Python
10
star
8

react-parcel-example

Simplest minimum viable React example app with Parcel Bundler
JavaScript
7
star
9

react-lazy-example

Example showcasing React.lazy
JavaScript
6
star
10

Django-Users-Boilerplate

🐍 A Django boilerplate with User Registeration, Login and Password change views. Uses django.auth
HTML
6
star
11

a-cashless-world

πŸ’Έβ€€Go cashless, because you will always find a spot where you can use your cashless payment method.β€€
Python
5
star
12

Auto

πŸ’» Browser automation as a service. Web Automation for end-users/enterprises based on their recorded actions
JavaScript
5
star
13

micro-pdf

HTML in PDF out. Node Micro-service to convert HTML into PDFs πŸ“„
JavaScript
4
star
14

aliens_vs_cannons

The aliens are inbound! Load the cannons. We must destroy them!
JavaScript
4
star
15

vigzmv.github.io

[Archived] 🌏 My Personal Website/Portfolio
CSS
3
star
16

LetsPay

Paytm Cash Coupons Generating And Sharing App
Python
2
star
17

reddit-gallery

#useThePlatform. Reddit reader made with Web components and JavaScript magic
HTML
2
star
18

vigneshm

$ npx vigneshm
JavaScript
1
star
19

twitt

[Deprecated] Real-time Twitter clone React-Native App with GraphQL-Node-MongoDB backend.
JavaScript
1
star
20

HerNurse

πŸ’ Progressive Web App that’s a Health & Social network for Women. β€’ Django
CSS
1
star
21

HealthHack

πŸš‘ Get Instant Result from your Test Reports analyzed over a huge data-set using machine learning classification
Python
1
star
22

localStorage-node

in memory localStorage polyfill for node.js utilizing ES6 proxies.
JavaScript
1
star