import React from 'react'
import ReactDOM from 'react-dom'
import axios from 'axios'
class ToDoList extends React.Component {
constructor(props) {
super(props)
this.state = {
lists: []
}
}
componentDidMount() {
axios.get('http://localhost:3001/api/v1/lists.json')
.then(response => {
console.log(response.data);
this.setState({lists: response.data})
})
}
render() {
return(
<div>
{this.state.lists.map((list) => {
return(
<div key={list.id}>
<h1>{list}</h1>
</div>
)
})}
</div>
)
}
}
ReactDOM.render(<ToDoList/>, document.getElementById('root'))
I am making simple to do app in react just wanted to display the json output, however getting this error Objects are not valid as a React child, please if someone can put me on right track
JSON.stringify()something like this:<h1>{JSON.stringify(list)}</h1>listobject?