-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
I am confused how to create the root action properly.
From docs:
// example reducer
export const reducer: Reducer<State> = (state = 0, action: RootAction) => {
// root actions
export type RootAction =
| ReactRouterAction
| CountersActions[keyof CountersActions]
| TodosActions[keyof TodosActions]
| ToastsActions[keyof ToastsActions];
// example action creators
import { createAction, getType } from 'react-redux-typescript';
// Action Creators
export const actionCreators = {
incrementCounter: createAction('INCREMENT_COUNTER'),
showNotification: createAction('SHOW_NOTIFICATION',
(message: string, severity: Severity = 'default') => ({
type: 'SHOW_NOTIFICATION', payload: { message, severity },
})
),
};
CountersActions[keyof CountersActions]
is equal to action creator types, not action types.
Should I define both action creator and actions separately?
Also ToastsActions[keyof ToastsActions];
doesn't work, but typeof ToastsActions[keyof typeof ToastsActions];
works.
SeanRoberts