[Redux] How should I store user data with Redux?

Share on facebook
Share on google
Share on twitter
Share on linkedin
organic-n-local-seo

https://www.reddit.com/r/reactnative/comments/eddsmf/redux_how_should_i_store_user_data_with_redux/

I'm building what is essentially a Tinder clone as a way to learn react native/other technologies. I am using AWS Amplify with Cognito to handle authentication. I have screens corresponding to signIn, signUp, confirmSignUp etc. where there are forms for entering user information such as email, password, confirm password, etc. which is then stored in the component's state and then passed to one of the Amplify.Auth functions for authentication.

After confirming signup, the user prompted to enter some data. Currently I have a flow of screens in a navigator where the user enters their:

name -> birthdate -> gender/gender seeking -> photos

This information is being passed as props to the next component in line, and I think it would be better to have it in a single location, especially down the line when the conversation screen will need to retrieve the user's matches etc. I want to switch to Redux for maintaining this data, but I am a bit unclear about how to achieve it in this context.

Should I be creating a Reducer that defines user state like this, and then update the fields as the user enters their information, or should this be split up somehow?

const initialState = {

user: {

name: "",

gender: "",

birthdate: "",

...

photos: [],

matches: [],

convos: [],

}

}

submitted by /u/Colin_Sack-or-Pick
[link] [comments]

About Us

Stay in touch with your prospects and customers and get high user engagement to gain trust as a prominent brand.

Recent Products

Recent Posts

Follow Us

Weekly Tutorial

Sign up for our Newsletter

Agree to our privacy policy.