Skip to content

abdulghani/reducercontext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

react usereducer context

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published