@abdulghani/reducercontext
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

React Reducer Context

use reducer to provide & maintain state inside context

Installation

npm npm install @abdulghani/reducercontext
yarn yarn add @abdulghani/reducercontext

Usage

Provide the reducer

import ReducerContext from "@abdulghani/reducercontext";
import reducer from "somewhere"
import ChildrenComponent from "somewhere"

const ParentComponent = () => {
  return (
    <ReducerContext reducer={reducer}>
      <ChildrenComponent/>
    </ReducerContext>
  )
}

Access the state & dispatch

import {useSelector, useDispatch, useThunk} from "@abdulghani/reducercontext";

const ChildrenComponent = () => {
  const state = useSelector(state => state);
  const dispatch = useDispatch();
  const thunk = useThunk();

  // use them
}

Readme

Keywords

none

Package Sidebar

Install

npm i @abdulghani/reducercontext

Weekly Downloads

0

Version

1.0.16

License

ISC

Unpacked Size

7.31 kB

Total Files

8

Last publish

Collaborators

  • abdulghani