tquinlan92-typescript-redux-utils
This package gives a few useful type-safe redux, react-redux, and react utilities.
makeNestedStore
makeNestedSimpleStore creates a nested redux store with thunk actions. It gives back reducers
to use with combineReducers
and actions
to update the state. The actions
include simpleActions
to change the state with the same name as the state properties. It also includes methods set
, to set a partial state with type checking, setAll
to set the state with type checking, reset
to reset a state to its initial state, resetAll
to reset the state whole to its initial state.
The second parameter takes middleware
to apply to the store returned.
;
The code below this shows the full basic usage. There's also a typescript create-react-app, redux, and redux thunk usage starting with ./src/index.tsx
demonstrating the usage in a real app. The app example is just a create-react-app with typescript and the instructions can be found here here.
Also you can access a sandbox using it without typescript here.
;;;; ; ; ; ; ; ; // Create a Selector using a exported selectors // Tests demonstrationg the usage of the actionsdescribe'dispatching state1 actions',;
mergeStateWithActions
mergeStateWithActions
takes two parameters intialState
and otherActions
. otherActions
are reducers that will be typed to to the initialState
passed and the second parameter to the reducer (the action type
) will be typed for the action creator
returned when used with makeNestedStore
;
createConnectProps
createConnectProps takes a AppState
as a generic type. It returns back a method to create connected props
using mapStateToProps
and mapDispatchToProps
as its two parameters.
;
connectProps
Usage of ;; ; ; )
withStyles
StyleComponent
creates a component with JSS styles given as props
withStyles
Usage of ; return }