getBeersSuccess(state, { payload: { beers, page }, }) { state.beers = [...state.beers, ...beers]; state.isLoading = false; state.error = null; state.page = page; state.hasMore = beers.length >= BEER_PER_PAGE; }
produce((state, action) => { switch(action.type) { case 'TICK': state.ticks += 1; break; } }, initialState)
async addDeep() { let oriState = this.getState(); this.setState( procude(oriState, draft => { draft.a.b.c.count += 1 }) ) }
export default function user(state = initial_state, action) { switch (action.type) { case '@auth/SIGN_IN_SUCCESS': return produce(state, draft => { draft.profile = action.payload.user; }); default: return state; } }
produce((state, action) => { switch(action.type) { case 'RECEIVED_MESSAGE': state.messages.push(action.payload); break; case 'SET_USERNAME': state.messages.push({ from: 'SYSTEM', text: `A user has changed its name to: ${action.payload}` }); } }, initialState)
function handleToggle(id) { const newToggle = produce(toggle, draft => { draft[id] = !draft[id]; }); setToggle(newToggle); }
produce( (draft, action) => { switch (action.type) { case UPDATE_FAVORITES: action.command === 'add'? draft[action.locationKey] = action.locationName : delete draft[action.locationKey]; return default: return draft } },{})
produce((state, action) => { switch(action.type) { case 'SET_USERNAME': state.username = action.payload; } }, initialState)
produce((state, action) => { switch(action.type) { case 'RECEIVED_MESSAGE': state.messages.push(action.payload); break; } }, initialState)
/* eslint-disable default-case, no-param-reassign */ const articleReducer = (state = initialState, action) => produce(state, draft => { switch (action.type) { case DEFAULT_ACTION: break; case SET_ARTICLES_ACTION: draft.articles = action.articles; break; default: } })
/* eslint-disable default-case, no-param-reassign */ const addCommentReducer = (state = initialState, action) => produce(state, (/* draft */) => { switch (action.type) { case DEFAULT_ACTION: break; } })
produce((state, action) => { switch(action.type) { case 'SET_USERNAME': state.username = action.payload; } }, initialState)
produce((state, action) => { switch(action.type) { case 'SET_USERNAME': state.username = action.payload; break; } }, initialState)
produce((state, action) => { switch(action.type) { case 'SET_USERNAME': state.username = action.payload; break; } }, initialState)
produce((state, action) => { switch(action.type) { case 'TICK': state.ticks += 1; break; } }, initialState)