Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Form): Remove Form onSubmit prop and serializer #1362

Closed
levithomason opened this issue Feb 21, 2017 · 0 comments
Closed

fix(Form): Remove Form onSubmit prop and serializer #1362

levithomason opened this issue Feb 21, 2017 · 0 comments

Comments

@levithomason
Copy link
Member

See #1348 and #833 for context. We will remove the special behavior of the onSubmit prop in favor of the vanilla React onSubmit behavior. This includes the serializer than passes the form data to the onSubmit callback.

More info:

We currently provide an onSubmit handler for the Form. This handler includes a Form data serializer. There are two issues with this:

  1. The serializer is DOM based and was planned to be migrated to migrated to a React callback mechanism, but this never happened. Interacting with the DOM is an antipattern in a React app.

  2. The callback and its serializer have encouraged improper usage of Forms and events. Users are encouraged to try to reach down the tree to invoke the onSubmit event so that they can retrieve the data out of their Form. This is also an antipattern in React. Data should be hoisted up the tree using controlled Form control components. Then, when the form data is needed, it is readily available in some higher state.

In the long term, we may still provide a component that makes working with Forms easier. However, this would be more akin to the DataTable #1133 which wraps a simple stateless Table and makes working with data state easier. We would likely provide some kind of wrapper that could manage the parent-child relationship of the Form and its controls and provide simple top level callbacks for capturing data. This might be similar to the AdvancedForm #527 experiment.

@levithomason levithomason changed the title Remove Form onSubmit prop and serializer fix(Form): Remove Form onSubmit prop and serializer Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant