-
-
Save skellock/fb15c65079bb973490cf7aa370f6fca9 to your computer and use it in GitHub Desktop.
react-navigation + redux
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
import { combineReducers } from 'redux' | |
import { reducer as nav } from './navigation/navigation.reducer' | |
// add `nav` into your root reducer | |
export default () => combineReducers({ | |
nav // you only see 1 thing here, but your app will have many reducers. | |
}) |
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
// then to trigger an action | |
import React, { PureComponent } from 'react' | |
import { connect } from 'react-redux' | |
import { Button } from 'react-native' | |
class SomeButton extends PureComponent { | |
render () { | |
return ( | |
<Button | |
onPress={this.props.navigateToAccount} | |
title='OMG LETS GO!!!!!!!' | |
/> | |
) | |
} | |
} | |
const mapDispatchToProps = dispatch => ({ | |
navigateToAccount: () => dispatch(navigateToAccount()) | |
}) | |
export default connect(null, mapDispatchToProps)(SomeButton) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment