1.5.3 • Published 5 years ago

react-formwork v1.5.3

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

React-Formwork

A ReactJS higher order component (HoC) to generate an HTML form from a Javascript object.

Using:

  • Install from npm:

npm install --save react-formwork

  • Import:

import Formwork from 'react-formwork'

  • Wrap a form component with the Formwork HoC:
class MyForm extends Component {
    render() {
        const { fields, submit, data } = this.props.formwork;
        return (
            <form>
                {fields}
                {submit}
                <pre>
                    {JSON.stringify(data, null, 2)}
                </pre>
            </form>
        )
    }
}

const model = {
    name: 'David',
    email: 'a@b.c',
    jobTitle: 'Developer'
};

export default Formwork(MyForm, {
    fields: model,
    data: model
});

In the example above we pass our JS object model to the Formwork HoC. We pull the generated HTML form fields, the submit button and our bound data object from props.formwork

For additional documentation visit the: GitHub repo

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago