Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (32 sloc) 832 Bytes
<h1>Show</h1>
<hr />
<div id="app"></div>
<!-- -->
<script type="text/babel">
class Show extends React.Component {
constructor(props) {
super(props);
this.state = {data: ''}
this.id = props.id
console.log(this.id)
}
componentDidMount(){
axios.get('/api/tasks_show/'+this.id ).then(response => {
this.setState({ data: response.data.docs[0] })
console.log( this.state.data )
})
.catch(function (error) {
console.log(error)
})
}
render(){
return (
<div>
<h1>title : {this.state.data.title}</h1>
<div>{this.state.data.content}</div>
</div>
)
}
}
ReactDOM.render(<Show id="<%= params_id %>" />, document.getElementById('app'));
</script>
You can’t perform that action at this time.