From 9c0a67c3c299608347fcf76bf51cf843a90f8169 Mon Sep 17 00:00:00 2001 From: Arun Ghosh Date: Tue, 6 Feb 2018 07:02:21 +0530 Subject: [PATCH] Formatted code snippets in Readme --- README.md | 111 ++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 9cc778c..cbc9b3d 100644 --- a/README.md +++ b/README.md @@ -47,54 +47,53 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { actions } from 'react-native-navigation-redux-helpers'; -const { - popRoute, - pushRoute, -} = actions; +const { popRoute, pushRoute } = actions; -const { - CardStack: NavigationCardStack -} = NavigationExperimental; +const { CardStack: NavigationCardStack } = NavigationExperimental; class GlobalNavigation extends Component { - render() { - return ( + render() { + return ( - ); - } + ); + } /* ... */ - onGoBack() { + onGoBack() { const { dispatch, navigation } = this.props; dispatch(popRoute(navigation.key)); - } + } onGoSomewhere() { const { dispatch, navigation } = this.props; - dispatch(pushRoute({ key: 'sowhere else' }, navigation.key)); + dispatch(pushRoute( + { + key: 'sowhere else', + }, + navigation.key, + )); } } function mapDispatchToProps(dispatch) { - return { - dispatch - }; + return { + dispatch, + }; } function mapStateToProps(state) { - return { - // XX: assuming you've registered the reducer above under the name 'cardNavigation' - navigation: state.cardNavigation - }; + return { + // XX: assuming you've registered the reducer above under the name 'cardNavigation' + navigation: state.cardNavigation, + }; } export default connect(mapStateToProps, mapDispatchToProps)(GlobalNavigation); - ``` ### Tab navigation @@ -129,50 +128,46 @@ import { actions as navigationActions } from 'react-native-navigation-redux-help const { jumpTo } = navigationActions; class ApplicationTabs extends Component { - _renderTabContent(tab) { - if (tab.key === 'feed') { - return ( - - ); - } - - /* ... */ - } - - render() { - const { dispatch, navigation } = this.props; - const children = navigation.routes.map( (tab, i) => { - return ( - dispatch(jumpTo(i, navigation.key)) } - selected={this.props.navigation.index === i}> - { this._renderTabContent(tab) } - - ); - }); - return ( - - {children} - - ); - } + _renderTabContent(tab) { + if (tab.key === 'feed') { + return ; + } + + /* ... */ + } + + render() { + const { dispatch, navigation } = this.props; + const children = navigation.routes.map((tab, i) => ( + dispatch(jumpTo(i, navigation.key))} + selected={this.props.navigation.index === i} + > + {this._renderTabContent(tab)} + + )); + return {children}; + } } function mapDispatchToProps(dispatch) { - return { - dispatch - }; + return { + dispatch, + }; } function mapStateToProps(state) { - return { - // XX: assuming your tab reducer is registered as 'tabs' - navigation: state.tabs - }; + return { + // XX: assuming your tab reducer is registered as 'tabs' + navigation: state.tabs, + }; } export default connect(mapStateToProps, mapDispatchToProps)(ApplicationTabs); + ``` ## Supported actions