stateful vs stateless components code example
Example: stateful component vs stateless component
class Parent extends Component {
constructor() {
super()
this.state = {
books: [],
favoriteAuthors: []
}
}
render() {
return (
<div>
<Books books={this.state.books} />
<FavoriteAuthors favoriteAuthors={this.state.favoriteAuthors} />
</div>
)
}
}