How to insert different screens value in the database by using ReactNative and Redux

Hello Friends,
I created signup API to registe user by using Nodejs and Mongodb. In the front side I am using React native and Redux. I have different screens in each field of signup (eg. FirstnameLastnameScreen for First andLastname field, GenderScreen for male or female field, BirthdateScreen for dateofBirth field, etc).
Can anyone suggest me how to insert those values in the database?

Presumable on your frontend, all of those values are stored in state. You need to collect them on the frontend and then make an http call to your backend to insert them into your DB.

Thank you for your response.
Do you mean that I will store them in Redux state?

Well, that would make sense. If there are things local to where you are sending the http call (or calling the function that makes the http call, etc) then you can just pass those in. In any case, you need to figure out how to get that data into the http call and send it to the backend. It’s impossible to say without seeing your setup, but getting some values locally, getting some values off redux, some combination… those are all valid possibilities.

See this as example:

Sure, but those will all need to be accessible somewhere if you want to submit them. If you’re using redux, then that is the logical place to keep/access them.

I am new on Redux
as you mean , for example, when I click Continue button, the value of each field store in redux, finally I can collect all field values in it and then it is easy to send all the values in the database.
Is it?

Yes, that is one very reasonable approach. There are other approaches, but the “grab everything from redux” approach makes sense. It’s hard to be sure without knowing more specifics, but based on what you’re saying, that sounds like a good bet.

It’s been a while since I’ve done something like that (I’ve been spoiled by Redux Saga) but I you can just grab the state crap off redux store in mstp. You can even create a selector to grab and transform that into a convenient object so you can put that logic elsewhere. Or not.

1 Like

Thanks a lot!
I will try it. If I get some difficulties, I will be back to you.
Thanks again

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.