<div id="root"></div>
class App extends React.Component{
state = {
todo:null
}
componentDidMount(){
axios.get('https://jsonplaceholder.typicode.com/todos/1')
.then(res=>{
this.setState({
todo:res.data
})
})
.catch(err=>console.log(err))
}
render(){
return (
<div>
<h1>hello</h1>
{this.state.todo ? <p>{this.state.todo.title}</p>:<p>Loading</p>}
</div>
)
}
}
ReactDOM.render(<App/>,document.querySelector('#root'))
View Compiled
This Pen doesn't use any external CSS resources.