- Notifications
You must be signed in to change notification settings - Fork0
React Hook useReducer with cancelable dispatch of thunks
License
PedroBern/react-hook-use-cancelable-thunk-reducer
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Custom implementation of react hookuseReducer that will cancel all dispatched actions if the component is unmounted and allows to dispatchthunk actions (that will be canceled either).
Open oncodesanbox.
yarn add use-cancelable-thunk-reducernpm i use-cancelable-thunk-reducerimportuseCancelableThunkReducerfrom'use-cancelable-thunk-reducer';const[state,dispatch]=useCancelableThunkReducer(reducer,initialState,callback,init);
useReducer first argument.
useReducer second argument.
default isundefined, if is afunction, when some action is canceled it is called with the action argument:callback(action).
useReducer last argument.
The thunk actions receive(dispatch, getState) args.
constthunkAction=args=>async(dispatch,getState)=>{dispatch({type:ACTION_SENT});conststate=getState(); ...}
About
React Hook useReducer with cancelable dispatch of thunks
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
