react-navigation
を反応ネイティブアプリケーションを制御するために使用しています。 Chat
タブでネイティブの反応ナビゲーション、TabNavigatorに反応し、タブ画面を変更したときにリクエストを送信する方法
const MainTab = TabNavigator({
Home: tabscreen(HomeScreen, '/home', 'home', 'home'),
Chat: tabscreen(ChatScreen, '/chat', 'chat', 'chat'),
Find: tabscreen(FindScreen, '/find', 'find', 'find'),
Profile: tabscreen(ProfileScreen, '/profile', 'profile', 'profile')
}, {
tabBarPosition: 'bottom',
swipeEnabled: false,
animationEnabled: false,
lazy: true,
//...other configs
tabBarOptions: {
// tint color is passed to text and icons (if enabled) on the tab bar
activeTintColor: '#1BBC9B',
inactiveTintColor: '#9B9B9B',
showIcon: true,
style: {
backgroundColor: '#F4F4F4',
borderTopWidth: 0,
height: 49
},
labelStyle: {
marginTop: 0,
marginLeft: 0,
marginRight: 0,
marginBottom: 1.5
}
}
});
const AppNavigator = StackNavigator({
Main: {
screen: MainTab ,
path: '/',
navigationOptions: {
// header: null,
headerVisible: false,
gesturesEnabled: false,
}
},
....
{
initialRouteName: 'Main',
mode: 'card',
headerMode: 'screen',
navigationOptions: {
headerVisible: false,
gesturesEnabled: true,
headerStyle: styles.headerStyle,
headerTitleStyle: styles.headerTitleStyle,
headerTintColor: 'white',
headerBackTitle: null,
}
});
、私はChatScreen
さんcomponentDidMount
関数内のリストデータを取得するために、バックエンドにリクエストを送信します。それはうまくいく。 ChatScreen
から別の画面をナビゲートするときは、何かをしてから別の画面の左上隅にある戻るボタンをクリックしてChatScreen
に戻ります。リストのデータをバックエンドから再度リクエストする必要がありますが、componentDidMount
doesnもう一度実行しないでください。
ChatScreen
が「A」という名前の別の画面にナビゲートする場合。 「A」画面のナビゲートはChatScreen
に戻ります。この場合、ChatScreen
はcomponentDidMount
関数を実行しません。
私が画面をChatScreen
に変更すると、リストデータを要求しています。 react lifecycle function
もう1つ、私は状態を制御するためにreduxを使用しています。
uはまた反応し、ナビゲーションタグを追加することができますか? – icemelt