react-lantern

0.0.2 • Public • Published

react-lantern

Illuminate data management through delcarative react components. It doesn't include any fancy http clients or switching methods and instead relies soley on fetch (for now).

Installation

yarn add react-lantern
npm install --save react-lantern

Fetch polyfill and furture signal support

Depending on your use case you may need to polyfill fetch.

There is also a good chance that future releases of this library will rely on AbortController which has somewhat limited support. whatwg-fetch does not polyfill for AbortController so another polyfill will be needed.

Usage

import React from 'react';
 
import { FetchProvider, Get } from 'react-lantern';
 
const FetchingAllDay = () => (
  <FetchProvider baseUrl="https://jsonplaceholder.typicode.com">
    <Get path="/posts">
      {({ loading, error, data }) => {
        if (loading) {
          return <div>Loading...</div>;
        }
 
        if (error) {
          return <div>Error...</div>;
        }
 
        return data.map((post: any) => <div key={post.id}>{post.title}</div>);
      }}
    </Get>
  </FetchProvider>
);

Package Sidebar

Install

npm i react-lantern

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

16 kB

Total Files

4

Last publish

Collaborators

  • deldreth