1.0.14 • Published 3 years ago

react-rest-store v1.0.14

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

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

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago