Redux-actions
- Ducks 패턴을 쉽게 구현하게 해주는 라이브러리
# terminal
$ npm i redux-actions
// src/redux/modules/filter.js
import { createActions, handleActions } from "redux-actions";
export const { showAll, showComplete } = createActions(
"SHOW_ALL",
"SHOW_COMPLETE",
{
prefix: "redux-start/filter",
}
);
// 초기값
const initialState = "ALL";
const reducer = handleActions(
{
SHOW_ALL: (state, action) => "ALL",
SHOW_COMPLETE: () => "COMPLETE",
},
initialState,
{ prefix: "redux-start/filter" }
);
// 리듀서
export default reducer;
댓글남기기