The Duck snippet for React/Redux. This snippet uses TypeScript syntax.
Trigger | Content |
---|---|
duck |
the snippet |
interface Action {readonly type?: string;}const defaultState = {};// Actionsconst ACTION = 'duck-name/ACTION';// Reducerexport default function reducer(state = defaultState, action: Action = {}) {switch (action.type) {case ACTION: {return state;}default: {return state;}}}// Action Creatorsexport function actionCreator() {return { type: ACTION };}
MIT License © Roman Nuritdinov (Ky6uk)
Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.