
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-formation
Advanced tools
[](https://travis-ci.org/k88hudson/react-formation) [](https://coveralls.io/
You can install React Formation from npm by running npm install react-formation. If you are using common js, you can require it like this:
var Formation = require('react-formation');
First, let's define the structure of your form. You can do that by using CreateForm just like how you would use React.createClass, including a render function:
var Formation = require('react-formation');
var Form = Formation.CreateForm({
render: function () {
return (<form>
<label>Name</label>
<input type="text" name="name" />
<label>Email</label>
<input type="text" name="email" />
<button>Submit</button>
</form>);
}
});
Next, add a getSchema method that returns a schema defining all the fields in the form, and link corresponding inputs with this.linkField:
var Form = Formation.CreateForm({
getSchema: function () {
return {
name: {required: true}
email: {validations: 'email'}
};
},
render: function () {
return (<form>
<label>Name</label>
<input type="text" valueLink={this.linkField('name')} />
<label>Email</label>
<input type="text" valueLink={this.linkField('email')} />
<button>Submit</button>
</form>);
}
});
Finally, add an onSuccess callback that gets called on a successful submit, and add this.submitForm as a callback to any submit buttons.
var Form = Formation.CreateForm({
getSchema: function () {
return {
name: {required: true}
email: {validations: 'email'}
};
},
onSuccess: function (data) {
console.log(data);
},
render: function () {
return (<form>
<label>Name</label>
<input type="text" valueLink={this.linkField('name')} />
<label>Email</label>
<input type="text" valueLink={this.linkField('email')} />
<button onClick={this.submitForm}>Submit</button>
</form>);
}
});
You can use your new Form class just like you would any other React element, including passing props. For example, if you wanted to render it directly into document.body:
React.render(<Form />, document.body);
Check out the guide and examples:
FAQs
[](https://travis-ci.org/k88hudson/react-formation) [](https://coveralls.io/
We found that react-formation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.