@theuybv/use-todos

1.0.5 • Public • Published

Simplifying the React Redux Example Todo List App with custom use-todos hooks

Example Redux Todo App: https://redux.js.org/basics/example

Made with create-react-library

NPM JavaScript Style Guide

Install

npm install --save @theuybv/use-todos

Redux Store Provider on App level

import React from "react";
import { render } from "react-dom";
import App from "./components/App";

import {TodosProvider} from "@theuybv/use-todos";

const Index = () => {

  return (
    <TodosProvider>
      {" "}
      <App />
    </TodosProvider>
  );
};

render(<Index />, document.getElementById("root"));

Actions, Selectors and Constants

import React from 'react';
import useTodos from "@theuybv/use-todos";
const SomeComp = () => {
  const {actions, selectors, VISIBILITY_FILTERS} = useTodos();
  const {toggleTodo, addTodo, setVisibility} = actions; // similar to stateToProps
  const {todos, active} = selectors; // similar to dispatchToProps
  const {SHOW_ALL, SHOW_COMPLETED, SHOW_ACTIVE} = VISIBILITY_FILTERS;


  return (
    <div>Do something with it!</div>
  )
}

License

MIT © theuybv

Readme

Keywords

none

Package Sidebar

Install

npm i @theuybv/use-todos

Weekly Downloads

8

Version

1.0.5

License

MIT

Unpacked Size

23.5 kB

Total Files

6

Last publish

Collaborators

  • tlimpanont