Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Created July 26, 2017 23:02
Show Gist options
  • Save scottdomes/bf17ec52fca4e8e0711bfd6720351f76 to your computer and use it in GitHub Desktop.
Save scottdomes/bf17ec52fca4e8e0711bfd6720351f76 to your computer and use it in GitHub Desktop.
docs-clone
import React, { Component } from 'react'
import './App.css'
class App extends Component {
state = { text: '' }
componentDidMount() {
window.fetch('http://localhost:3001/notes/1').then(data => {
data.json().then(res => {
this.setState({ text: res.text })
})
})
}
handleChange = e => {
this.setState({ text: e.target.value })
}
render() {
return (
<textarea
value={this.state.text}
onChange={this.handleChange}
/>
)
}
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment