Skip to content

Instantly share code, notes, and snippets.

@hpjaj
Created November 14, 2018 17:57
Show Gist options
  • Save hpjaj/934542d19f41751be17abcb977426649 to your computer and use it in GitHub Desktop.
Save hpjaj/934542d19f41751be17abcb977426649 to your computer and use it in GitHub Desktop.
// 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