You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the component mounts I dispatch loadUser action with the userId passed as prop.
This makes a request to the API, and add the user response to my users state.
Now, I want my Profile component to receive the user to render as prop.
So basically I want to do something like:
Obviously it can't work because I don't have access to props.
I can't use a state like selectedProfile to filter because I'm rendering multiple profiles in my navigation stack, each one has different userId, if I use global selectedProfile state, it breaks the back button.
The only workaround I found is to create a ProfileContainer component, that will filter the state by its prop and pass the single user to Profile component.
This is more a react-redux issue... I may be missing something, but it seems very simple to me, use "ownProps" argument that is passed to mapStateToProps, so your code above will look:
Hi,
I'm using redux with react-native and so far it's great!
In my app I have user profiles, and my state looks like:
Now I have a
<Profile>
component that render a single userWhen the component mounts I dispatch
loadUser
action with theuserId
passed as prop.This makes a request to the API, and add the user response to my
users
state.Now, I want my Profile component to receive the user to render as prop.
So basically I want to do something like:
Obviously it can't work because I don't have access to props.
I can't use a state like
selectedProfile
to filter because I'm rendering multiple profiles in my navigation stack, each one has different userId, if I use global selectedProfile state, it breaks the back button.The only workaround I found is to create a
ProfileContainer
component, that will filter the state by its prop and pass the single user toProfile
component.Does it make sense? Anybody else encounter this issue?
Thanks,
Ran.
The text was updated successfully, but these errors were encountered: