-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e011e5
commit 4a9256b
Showing
8 changed files
with
442 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import $ from 'jquery'; | ||
|
||
export default class App extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
text: '', | ||
update: 'text will change if button works', | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
$.get('/text'); | ||
} | ||
|
||
handleChange(e) { | ||
let newState = {}; | ||
newState[e.target.name] = e.target.value; | ||
this.setState(newState); | ||
} | ||
|
||
handleSubmit(e) { | ||
e.preventDefault(); | ||
console.log('handleSubmit fires'); | ||
|
||
let data = { | ||
text: this.state.text | ||
}; | ||
fetch('/text', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8' | ||
}, | ||
body: JSON.stringify(data) | ||
}); | ||
} | ||
|
||
|
||
render() { | ||
return ( | ||
<div> | ||
<h1>Reviews</h1> | ||
<form onSubmit={this.handleSubmit}> | ||
<label> Text | ||
<input name="text" value={this.state.text} onChange={this.handleChange}/> | ||
</label> | ||
<button>Submit</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import App from './components/App.jsx'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('app')); |
Oops, something went wrong.