Skip to content

Instantly share code, notes, and snippets.

@arqex
Created January 18, 2016 18:37
Show Gist options
  • Save arqex/d82335a5fa4d09fa487c to your computer and use it in GitHub Desktop.
Save arqex/d82335a5fa4d09fa487c to your computer and use it in GitHub Desktop.
10.nonFunctionalReact
var MyForm = React.createClass({
render: function(){
return (
<ValidationForm ref="form" onSubmit={ this.validates }>
<Input name="title" validation="required" />
<Input name="age" validation="required,number" />
<Input name="email" validation={ value => value.match(/\S+@\S+\.\S+/) } />
</ValidationForm>
);
},
validates: function(){
// Use the from API
if( this.refs.form.validates() ){
// Handle the form
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment