Skip to content

Instantly share code, notes, and snippets.

@walter76
Last active July 3, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walter76/ae738d28c2afce91429e0a5ccfaca260 to your computer and use it in GitHub Desktop.
Save walter76/ae738d28c2afce91429e0a5ccfaca260 to your computer and use it in GitHub Desktop.
React Component Form Field
import React from 'react'
import { Form } from 'semantic-ui-react'
class SomeFormComponent extends React.Component {
constructor(props) {
super(props)
this.state = {
name: ''
}
this.onChange = this.onChange.bind(this)
}
onChange(e) {
this.setState({
name: e.target.value
})
}
render() {
const { name } = this.state
return (
<Form>
<Form.Field>
<label htmlFor="name">Name</label>
<input
id="name"
name="Name"
placeholder="Name"
value={name}
onChange={this.onChange}
/>
</Form.Field>
</Form>
)
}
}
export default SomeFormComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment