-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
38 lines (29 loc) · 797 Bytes
/
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
import React, { Component } from "react";
import Table from './Table'
import Form from './Form'
class App extends Component {
state = {
characters: [
]
}
removeCharacter = (index) => {
const {characters} = this.state
this.setState({
characters: characters.filter((character, i) => {
return i !== index
})
})
}
handleSubmit = (character) => {
this.setState({characters: [...this.state.characters, character]})
}
render() {
return (
<div className="container">
<Table characterData = {this.state.characters} removeCharacter= {this.removeCharacter} />
<Form handleSubmit={this.handleSubmit}/>
</div>
);
}
}
export default App