Skip to content

Instantly share code, notes, and snippets.

@paranoidjk
Forked from arqex/formComponent.js
Created January 22, 2016 06:26
Show Gist options
  • Save paranoidjk/8d19c47c291d699fc983 to your computer and use it in GitHub Desktop.
Save paranoidjk/8d19c47c291d699fc983 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