5.5.9 • Published 5 months ago

frmx v5.5.9

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

license latest version last commit bundle size total stars downloads open issues

Simple, Performant, Lightweight React Forms

frmx is lightweight (~9kb minified / ~3kb gzipped) and eliminates most of the boilerplate code and headaches when building forms with React, without assuming anything about the shape of your form data or the nesting / styling of your component.

But, unlike other librairies, you can take frmx one step further and use it to manager all kinds of user inputs, such as settings or complex search filters for instance.

It is heavily relied on in production at my company (it actually manages all user inputs) and used by several thousands users a month, yet having no known (open) issue.

CodeSandbox

Check the demo here

Docs

Check the documentation here

Goal

Overall, the goal is to start from the data you need and allow you to write code like this and never worry about wiring state or passing stuff down the prop chain again:

<Form
initialValues={{foo: "", bar: {baz:""}}}
onSubmit={data => doSmthg(data)}
// disableSubmitIfInvalid // comment out onInvalidSubmit to use this prop!
// disableIfNoUpdates // Additional rules to disable submission
onInvalidSubmit={() => alert("invalid form")}
schemaValidation={{ bar: { baz: str => str.length > 2 } }}
>
    <CustomInput1 path="bar.baz" />
    <CustomInput2 path="foo" />
    <CustomSubmitButton />
</Form>

How it works

To get both performance and flexibility with a simple API, frmx uses React's context API only to store refs, expose a few getter / setters methods and give forms a unique id. That way, updating form data doesn't trigger rerendering everything inside the <Form/> component. All fields keep track of their own state and only update the refs as a side effect, while various events regarding form validity / submitting / resetting are passed through synthetic events that do not trigger rerenders of the context provider itself.

v5 Breaking changes

frmx no longer supports diffing for lack of usage. It may or may not be reincluded in the package later on.

The renderDiv prop for the <Form> component is gone, and has been replaced with the render prop which accepts a string with the name of the tag you wish to create. The default is "div" in order to support nested forms - which happends way more often than you'd think when you use frmx to handle all of your user inputs - but you can pass it any tag name, including of course the "form" tag (those cannot be nested).

v4 Breaking changes

Before switching to v4, please note that components have been renamed in order to provide better interoperability between librairies.

Also, the field prop has been renamed to path to avoid confusion.

Last but not least, the <Form /> component's disableSubmitIfInvalid has been renamed to disableIfInvalid.

5.5.9

5 months ago

5.5.8

1 year ago

5.5.7

1 year ago

5.5.6

1 year ago

5.5.5

1 year ago

5.5.4

1 year ago

5.5.3

1 year ago

5.5.2

1 year ago

5.5.1

1 year ago

5.5.0

1 year ago

5.4.1

1 year ago

5.4.0

2 years ago

5.3.2

2 years ago

5.3.1

2 years ago

5.3.0

2 years ago

5.2.7

2 years ago

5.2.6

2 years ago

5.2.5

2 years ago

5.2.4

2 years ago

5.2.3

2 years ago

5.2.2

2 years ago

5.2.1

2 years ago

5.2.0

2 years ago

5.1.26

2 years ago

5.1.25

2 years ago

5.1.24

2 years ago

5.1.23

2 years ago

5.1.22

2 years ago

5.1.21

2 years ago

5.1.20

2 years ago

5.1.19

2 years ago

5.1.17

2 years ago

5.0.0-alpha.6

2 years ago

5.0.0-alpha.5

2 years ago

5.0.0-alpha.4

2 years ago

5.0.0-beta.0

2 years ago

5.0.0-alpha.3

2 years ago

5.0.0-alpha.2

2 years ago

5.0.0-alpha.1

2 years ago

5.0.0-alpha.0

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

5.1.9

2 years ago

5.1.8

2 years ago

5.1.7

2 years ago

5.1.6

2 years ago

5.1.5

2 years ago

5.1.4

2 years ago

5.1.3

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.6

2 years ago

5.1.16

2 years ago

5.1.15

2 years ago

5.1.14

2 years ago

5.1.13

2 years ago

5.1.11

2 years ago

5.1.10

2 years ago

4.1.5

2 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.12

3 years ago

4.0.14

3 years ago

4.0.13

3 years ago

4.0.10

3 years ago

4.0.9

3 years ago

4.0.8

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.7

3 years ago

4.0.6

3 years ago

3.8.12

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

3.8.11

3 years ago

3.8.10

3 years ago

3.8.9

3 years ago

3.8.4

3 years ago

3.8.3

3 years ago

3.8.8

3 years ago

3.8.7

3 years ago

3.8.6

3 years ago

3.8.5

3 years ago

3.8.2

3 years ago

3.8.0

3 years ago

3.8.1

3 years ago

3.7.13

3 years ago

3.7.5

3 years ago

3.7.9

3 years ago

3.7.8

3 years ago

3.7.7

3 years ago

3.7.6

3 years ago

3.7.11

3 years ago

3.7.12

3 years ago

3.7.10

3 years ago

3.7.4

3 years ago

3.7.3

3 years ago

3.7.2

3 years ago

3.7.1

3 years ago

3.7.0

3 years ago

3.6.2

3 years ago

3.5.7

3 years ago

3.5.6

3 years ago

3.5.9

3 years ago

3.5.8

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.4.8

3 years ago

3.5.5

3 years ago

3.5.4

3 years ago

3.5.3

3 years ago

3.5.2

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.7

3 years ago

3.4.6

3 years ago

3.4.5

3 years ago

3.4.4

3 years ago

3.4.3

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.1

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago