react-rest-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

react-rest-store

Apollo inspired library to connect redux, local-storage, and rest domains seamlessly.

NPM JavaScript Style Guide

What is this?

It is a library to attempt to make life easier by reducing boilerplate introduced with Redux + API connections.

Features

  • Tracking Rest executions (does not execute same command twice).
  • Exclusive use of hooks for clean code.
  • Persisting data in a redux store.
  • Persisting data over refreshes (localstorage).
  • Has intervals.
  • Has manually fetching.
  • Exposes native libraries.

Todo!

Minimize the laundry list of dependencies.

Install

npm install --save react-rest-store

Simplest Usage

Example here

import React from 'react';

import {createRrs } from 'react-rest-store';

const { Provider, domain } = createRrs({
  domain: {
    baseURL: 'https://jsonplaceholder.typicode.com',
  },
});

const Todos = () => {
  const { data: todos, loading } = domain.useGet('/todos');

  if (loading) {
    return <div>Loading...</div>
  }

  return (
    <table>
      <thead>
        <tr>
          <th>Title</th>
          <th>Completed</th>
        </tr>
      </thead>
      <tbody>
        {todos.map((todo: any) => (
          <tr key={todo.id}>
            <td>{todo.title}</td>
            <td>{todo.completed && 'X'}</td>
          </tr>
        ))}
      </tbody>
    </table>
  );
};

const App = () => (
  <Provider>
    <Todos />
  </Provider>
);

export default App;

License

MIT © vssrcj

Readme

Keywords

none

Package Sidebar

Install

npm i react-rest-store

Weekly Downloads

2

Version

1.0.14

License

MIT

Unpacked Size

186 kB

Total Files

19

Last publish

Collaborators

  • vssrcj