react-jsonschema
Version:
React forms with JSONSchema
87 lines (66 loc) • 1.73 kB
Markdown
# React JSONSchema
[](https://travis-ci.org/vutran/react-jsonschema) [](https://coveralls.io/github/vutran/react-jsonschema?branch=develop) []()
> Create beautiful forms with [JSONSchema](http://json-schema.org)
> Inspired by [react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form) from Mozilla.

## Installation
````bash
$ npm install --save react-jsonschema
````
## Usage
````js
import Form from 'react-jsonschema';
const schema = {
"title": "Basic Demo",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"title": "First Name",
},
"lastName": {
"type": "string",
"title": "Last Name",
},
"age": {
"type": "integer",
"title": "Age",
"description": "Age in years",
},
},
};
const formData = {
firstName: '',
lastName: '',
age: '',
};
ReactDOM.render(
<Form
schema={schema}
formData={formData}
onError={errors => {
console.log(errors);
}}
onSubmit={data => {
console.log(data);
}}
/>,
document.getElementById('app'),
);
````
## Contributing
1. Clone the repository
2. Install dependencies
**With `npm`:**
```bash
$ npm install
```
**With [`yarn`](https://github.com/yarnpkg/yarn):**
```bash
$ yarn
```
3. Run tests: `npm t`
## References
- [JSON Schema](http://json-schema.org/)
## License
MIT © [Vu Tran](https://github.com/vutran/)