-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
React, Redux for complex nested forms #123
Comments
Check out redux-form for a sane validation approach. I'm closing because it's not an actionable issue—this type of question is better asked on StackOverflow. |
A complex form usually entails multiple controls of several types and is likely to require interaction with a number of different domain models and perhaps client-side caching of unsaved changes. As Redux users will see, creating even medium-complexity forms there are performance issues handling input Aside: Because React throws a |
Hey guys,
I'm developing an app with pretty complex form logic. I'm trying to follow the advice of @gaearon about Smart and Dumb components.
My form is dynamic, and is constructed out of several
fieldsets
. The fieldsets that are being displayed are chosen based on user roles.Each fieldset has it's own validation logic and own actions to retrieve async data based on user input, in order to guide the user towards completion of the form.
Not only that, but the inputs inside each fieldset are dynamic as well. Again, based on user permissions.
I've tried to implement this use case using only one Smart Component (the route handler), however without much success.
As I see it, in such use case, a fieldset is both a smart component and a dumb component. It both
connects
to redux, in order to dispatch some private use case actions and it also acts as a dumb component to bubble up state changes using events.Am I getting it right?
In your opinion, where does validation should take place? Inside each fieldset or in the route handler?
Basically, I'm planning to use same validation logic both on client and server.
The model that I'm validating on the server, looks something like:
The original way I tried to implement it, is to is to simply validate in the route handler level, but it got really messy and complex. Basically unmaintainable. Some validation logic needs to be async.
On the server I prefetch all the validation logic before validating.
On the client, it's a bit harder because the fieldsets are dynamic.
What do you think? How would you approach nested forms with react-redux?
Thanks.
The text was updated successfully, but these errors were encountered: