Last active
November 10, 2017 12:12
-
-
Save shubhnik/c3826edc44d80a7bdd5ed7fec3720f0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple demo screen1 to demonstrate dispatching actions to update navigation state and navigate to screen2. | |
// Don not forget to check the complete code here ---> https://github.com/shubhnik/redux-react-navigation | |
class Screen1 extends Component { | |
navigate = () => { | |
const navigateToScreen2 = NavigationActions.navigate({ | |
routeName:'screen2', | |
params:{name:'Shubhnik'} | |
}) | |
// navigateToscreen2 will look like this: | |
/* | |
{ | |
"type": "Navigation/NAVIGATE", | |
"routeName": "screen2", | |
"params":{ | |
"name":"Shubhnik" | |
} | |
} | |
*/ | |
// The navigateToScreen2 action is dispatched and new navigation state will be calculated in basicNavigationReducer here ---> https://gist.github.com/shubhnik/b55602633aaeb5919f6f3c15552d1802 | |
this.props.navigation.dispatch(navigateToScreen2) | |
} | |
render(){ | |
return( | |
<View style={{flex: 1}}> | |
<TouchableOpacity | |
onPress={this.navigate} | |
> | |
<Text>Navigate to screen2</Text> | |
</TouchableOpacity> | |
</View> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment