File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,16 @@ <h1>Goal</h1>
215215function List ( props ) {
216216return (
217217< ul >
218- < li > LIST</ li >
218+ { props . items . map ( ( item ) => (
219+ < li key = { item . id } >
220+ < span >
221+ { item . name }
222+ </ span >
223+ < button onClick = { ( ) => props . remove ( item ) } >
224+ X
225+ </ button >
226+ </ li >
227+ ) ) }
219228</ ul >
220229) ;
221230}
@@ -233,14 +242,19 @@ <h1>Goal</h1>
233242id : generateId ( ) ,
234243} )
235244) ;
236- }
245+ }
246+
247+ removeItem = ( todo ) => {
248+ this . props . store . dispatch ( removeTodoAction ( todo . id ) )
249+ }
250+
237251render ( ) {
238252return (
239253< div >
240254< h1 > Todo List</ h1 >
241255< input type = "text" placeholder = "add todo" ref = { ( input ) => ( this . input = input ) } />
242256< button onClick = { this . addItem } > Add ToDo</ button >
243- < List />
257+ < List remove = { this . removeItem } items = { this . props . todos } />
244258</ div >
245259) ;
246260}
@@ -258,14 +272,18 @@ <h1>Todo List</h1>
258272id : generateId ( ) ,
259273} )
260274) ;
261- }
275+ }
276+
277+ removeItem = ( goal ) => {
278+ this . props . store . dispatch ( removeGoalAction ( goal . id ) )
279+ }
262280render ( ) {
263281return (
264282< div >
265283< h1 > Goals</ h1 >
266284< input type = "text" placeholder = "add goals" ref = { ( input ) => ( this . input = input ) } />
267285< button onClick = { this . addItem } > Add Goals</ button >
268- < List />
286+ < List remove = { this . removeItem } items = { this . props . goals } />
269287</ div >
270288) ;
271289}
You can’t perform that action at this time.
0 commit comments