Skip to content

Instantly share code, notes, and snippets.

@ohager
Created September 12, 2016 16:50
Show Gist options
  • Save ohager/0d51222c61a73fd28a214e52e4aa2155 to your computer and use it in GitHub Desktop.
Save ohager/0d51222c61a73fd28a214e52e4aa2155 to your computer and use it in GitHub Desktop.
React Functional stateless component
// it's just a function! no createClass or extend React.Component
const Value = function(props){
render : {
return(
<div className={`${props.span} columns`}>
<label>{props.label}</label>
<input className="u-full-width" type="text"
value={props.value} onChange={()=>{}} disabled/>
</div>
)
}
};
Value.propTypes = {
span : React.PropTypes.string,
label : React.PropTypes.string,
value : React.PropTypes.any,
};
// ... use like this, dude!
<div className="form-body">
<div className="row">
<Value span="two" label="Id" value={order.id}/>
<Value span="two" label="Internal Order Number" value={order.orderNumber}/>
<Value span="two" label="Creation Date" value={order.createDate}/>
<Value span="two" label="Laboratory" value={order.laboratory}/>
<div className="two columns">&nbsp;</div>
<Value span="two" label="Status" value={order.status}/>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment