-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestingNavigators.js
61 lines (49 loc) · 1.41 KB
/
NestingNavigators.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React,{Component} from 'react';
import {View, Text, StyleSheet, AppRegistry,Button} from 'react-native';
import {StackNavigator,TabNavigator} from 'react-navigation';
// import ChatScreen from './StackNavigatorDemo'
class RecentChatScreen extends Component{
render(){
return(
<View>
<Button
onPress={() => this.props.navigation.navigate('Chat', { user: 'jack' ,password:'456'})}
title='chat with jack'/>
</View>
);
}
}
class AllContactsScreen extends Component{
render(){
return(
<View>
<Text>List of all contact!</Text>
</View>
);
}
}
class ChatScreen extends Component{
static navigationOptions=({navigation})=>{
title:`Chat with ${navigation.state.params.user}`
};
render(){
const {params}=this.props.navigation.state
return (
<View>
<Text>chat with {params.user} ;password:{params.password}</Text>
</View>
);
}
}
const MainScreenNavigator=TabNavigator({
Home:{screen:RecentChatScreen},
All:{screen:AllContactsScreen},
})
MainScreenNavigator.navigationOptions={
title:'My Chat',
}
const SimpleApp=StackNavigator({
Home:{screen:MainScreenNavigator},
Chat:{screen:ChatScreen}
})
AppRegistry.registerComponent('NavigationDemo', () => SimpleApp);