mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
got add, remove, and edit actions working
This commit is contained in:
@@ -2,15 +2,12 @@ import { createReducer } from './createReducer';
|
||||
import { Store, FilterTypes } from '../store';
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
let counter = 0;
|
||||
|
||||
export const reducer = combineReducers<Store>({
|
||||
todos: createReducer<Store['todos']>(
|
||||
{},
|
||||
{
|
||||
add(draft, action) {
|
||||
const id = String(counter++);
|
||||
draft[id] = { label: action.label, completed: false };
|
||||
draft[action.id] = { label: action.label, completed: false };
|
||||
return draft;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user