Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

firebase - Trying to pass object through screens with react navigation

I am having issues passing an object through screens using react navigation : I currently have a user object received from connecting to firebase, so i know i have the object and my user is connected. However, i can't seem to find the best way to pass it to the screen after connection, which way is better ? Like this :

navigation.navigate('User Profile', {user: user})

(This line is called after getting the document in which the user information is stored in and upon pressing the login button)

Or like this :

{ user ?(
                <Tab.Screen name="User Profile">
                    {props => <ConnectedProfileScreen {...props} extraData={user}/>}
                </Tab.Screen>
            ) : (
                <Tab.Screen name ="Profile" component={ProfileScreen}/>
            )}

(This chunk is part of my BottomTabNavigator, and renders differently based on if the mobile app is detecting a connected user or not)

Second thing, my bottom tab is rendered with "profile" at first when no user is connected, when an user connects, "User profile" is rendered in the tab replacing the "profile" tab, but when I disconnect, "user profile" is still rendered, how can I manage to re-render "profile" upon disconnect ?

question from:https://stackoverflow.com/questions/65898264/trying-to-pass-object-through-screens-with-react-navigation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...