const INCREASE = 'counter/INCREASE';
const DECREASE = 'counter/DECREASE';
export const increase = () => ({
type: INCREASE,
});
export const decrease = () => ({
type: DECREASE,
});
const initialState = {
number: 0,
};
function counter(state = initialState, action) {
switch (action.type) {
case INCREASE:
return {
number: state.number + 1,
};
case DECREASE:
return {
number: state.number - 1,
};
default:
return state;
}
}
export default counter;
export default
하나만 가능
{}없이 import함
export
여러 개 가능
{}로 import할 수 있음
import { combineReducers } from 'redux';
import counter from './counter';
import todos from 'todos';
const rootReducer = combineReducers({
counter,
todos,
});
export default rootReducer;