Created
November 14, 2018 17:57
-
-
Save hpjaj/934542d19f41751be17abcb977426649 to your computer and use it in GitHub Desktop.
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
// app/javascript/components/NewPost.js | |
import React from 'react' | |
class NewPost extends React.Component { | |
state = { | |
title: '', | |
body: '' | |
} | |
handleChange = event => { | |
this.setState({ [event.target.name]: event.target.value }); | |
} | |
render() { | |
return ( | |
<div> | |
<h1>New Post</h1> | |
<form> | |
<input | |
name="title" | |
onChange={this.handleChange} | |
placeholder="title" | |
type="text" | |
/> | |
<input | |
name="body" | |
onChange={this.handleChange} | |
placeholder="body" | |
type="text" | |
/> | |
<button>Create Post</button> | |
</form> | |
</div> | |
) | |
} | |
} | |
export default NewPost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment