Using redux-forms, is it possible to share the same state between two forms (View 1, View 2)?

132 Views Asked by At

I am looking for a small help whilst experimenting #react #redux-forms :

Problem statement: User should be able to add a student, query student details using a unique id and edit student details. Lets not worry about the negative scenarios just as yet.

Query: I initialise my Form using a unique student id that's available to me. (view 1, which includes fields -- First name, Last name, Course and buttons -- Submit, Add/edit more details)

However, there's an "Add/edit more details" option on the form which gives the user the ability to add more details against a student. (view 2, which includes -- email, phone number, etc.. they can add/remove more than one of each of these details)

I wanted to know if it's possible to share the same store between the two views?

if I click on edit more details and navigate to view 2 after changing the First name, then First name changes should reflect in View 2 as well. More like sharing the same model.

Or if there is an alternate solution to this? For me to be able to eventually update the database irrespective of changes being made in view 1 or view 2.Thanks in advance :)

Images for the views Images for the views

1

There are 1 best solutions below

3
adred On

If you can update the details based on same API request, you can store them under same form name (ps form name is specific to a store in redux-form). I don't see a problem in using same store / form.