-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathApp.js
50 lines (45 loc) · 1.01 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react'
import Header from './Header'
import NoteList from './NoteList'
import Footer from './Footer'
import '../styles/App.css';
class App extends React.Component {
constructor() {
super()
this.state = {
notes: [{
title: 'MSD Code Academy',
text: 'Let\'s crete React app with a few components.',
uuid: 1
}]
}
}
addNoteToList = (note) => {
const {notes} = this.state
this.setState({
notes: notes.concat(note)
})
}
removeNoteFromList = (noteId) => () => {
const {notes} = this.state
const newNotes = notes.filter((note) => {
return note.uuid !== noteId
})
this.setState({
notes: newNotes
})
}
render() {
const {notes} = this.state
return (
<div className="App">
<div>
<Header onAddNote={this.addNoteToList} />
<NoteList notes={notes} removeNoteFromList={this.removeNoteFromList} />
</div>
<Footer />
</div>
)
}
}
export default App