Skip to content

Instantly share code, notes, and snippets.

@sirgallifrey
Last active August 3, 2017 00:39
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 sirgallifrey/70f71fe7d5e55a029b33aff964775a6c to your computer and use it in GitHub Desktop.
Save sirgallifrey/70f71fe7d5e55a029b33aff964775a6c to your computer and use it in GitHub Desktop.
specialized components
import React from 'react';
import Label from './label';
import Input from './input';
function Field (props) {
return (
<div className="form-group">
<Label>{props.label}</Label>
<Input type={props.type} onChange={props.onChange} value={props.value}/>
</div>
);
}
import React from 'react';
import Field from './field';
class Index extends React.Component {
handleChange = () => {
//update field state
}
render() {
return (
<form>
<Field label="Nome" type="text" onChange={this.handleChange}/>
<Field label="Email" type="email" onChange={this.handleChange}/>
<Field label="Telephone" type="tel" onChange={this.handleChange}/>
</form>
);
}
}
import React from 'react';
function Input (props) {
return (
<input {...props}/>
);
}
import React from 'react';
function Label (props) {
return (
<label className="form-label">{ props.children }</label>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment