[React] Context Module Function 패턴
·
React/실험실
// src/context/counter.js const CounterContext = React.createContext() function CounterProvider({step = 1, initialCount = 0, ...props}) { const [state, dispatch] = React.useReducer( (state, action) => { const change = action.step ?? step switch (action.type) { case 'increment': { return {...state, count: state.count + change} } case 'decrement': { return {...state, count: state.count - change} }..