From 78a76f7893b9990db9bf42cd08ec7c0513471a57 Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Mon, 3 Sep 2018 00:18:16 -0300 Subject: [PATCH 1/6] WIP --- src/navigationStore.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/navigationStore.js b/src/navigationStore.js index b342df1bc..8252f8684 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -350,6 +350,9 @@ function originalRouteName(routeName) { } return routeName; } +function isStatelessComponent(Component) { + return (!Component.prototype || typeof Component.prototype.render !== 'function'); +} function extendProps(props, store: NavigationStore) { if (!props) { return {}; @@ -380,7 +383,7 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { // detect if the component is not functional stateless // not sure if Component can be string-defined ("div") here // may be there is a better way to detect stateless function component, but this should work - if (!Component.prototype || Component.prototype.render) { + if (isStatelessComponent(Component)) { class Wrapped extends React.Component { static propTypes = { navigation: PropTypes.shape().isRequired, @@ -399,6 +402,14 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { if (this.ref && this.ref.onEnter) { this.ref.onEnter(navigation && navigation.state); } + // WIP + this.subs = []; + if (this.ref && this.ref.onWillFocus) { + this.subs.push(navigation.addListener('willFocus', this.ref.onWillFocus)); + } + if (this.ref && this.ref.onDidFocus) { + this.subs.push(navigation.addListener('didFocus', this.ref.onDidFocus)); + } } componentWillUnmount() { @@ -409,6 +420,8 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { if (this.ref && this.ref.onExit) { this.ref.onExit(navigation && navigation.state); } + // WIP + this.subs.forEach(sub => sub.remove()); this.ref = null; } From 512d7d175ddfe478396519ef829e45a393cb0dfc Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Mon, 3 Sep 2018 00:25:48 -0300 Subject: [PATCH 2/6] Debug refresh key --- src/navigationStore.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/navigationStore.js b/src/navigationStore.js index 8252f8684..fd928a20a 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -892,6 +892,7 @@ class NavigationStore { refresh = (data) => { const params = filterParam(data); const { key } = getActiveState(this.state); + console.log('KEY', key); this.dispatch(NavigationActions.setParams({ key, params })); }; From a2ad9ee19774fdb6371ad8a36296461b41703c9a Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Mon, 3 Sep 2018 06:57:22 -0300 Subject: [PATCH 3/6] Lint --- src/navigationStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/navigationStore.js b/src/navigationStore.js index fd928a20a..0273f50e6 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -351,7 +351,7 @@ function originalRouteName(routeName) { return routeName; } function isStatelessComponent(Component) { - return (!Component.prototype || typeof Component.prototype.render !== 'function'); + return !Component.prototype || typeof Component.prototype.render !== 'function'; } function extendProps(props, store: NavigationStore) { if (!props) { From 33489e3ab5c549d855a027f7504fd07247b8e400 Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Mon, 3 Sep 2018 09:03:31 -0300 Subject: [PATCH 4/6] CHANGELOG update --- CHANGELOG.md | 57 ++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0331957b..aa86f16c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,26 @@ [Full Changelog](https://github.com/aksonov/react-native-router-flux/compare/4.0.1...HEAD) +**Implemented enhancements:** + +- New release of `react-navigation` is available \(v2.12.1\) [\#3222](https://github.com/aksonov/react-native-router-flux/issues/3222) +- Upgrade react-navigation to v.2.12.1 [\#3223](https://github.com/aksonov/react-native-router-flux/pull/3223) ([daviscabral](https://github.com/daviscabral)) + +**Fixed bugs:** + +- Can't pass props to scene from Action.key\(props\). Think this way should work too. [\#3236](https://github.com/aksonov/react-native-router-flux/issues/3236) +- Actions.reset: There is no route defined for Key X [\#3194](https://github.com/aksonov/react-native-router-flux/issues/3194) +- Stack of same scene not working anymore after update from 4.0.0-beta-28 to 4.0.1 [\#3176](https://github.com/aksonov/react-native-router-flux/issues/3176) +- \[Fix \#3194 \#3176\] Adjust reset to work with nested routes [\#3237](https://github.com/aksonov/react-native-router-flux/pull/3237) ([daviscabral](https://github.com/daviscabral)) +- add Statusbar marginTop for navTransparent [\#3212](https://github.com/aksonov/react-native-router-flux/pull/3212) ([rikochet](https://github.com/rikochet)) + **Closed issues:** +- How can i get the props after Actions.popTo in the previous scene? [\#3241](https://github.com/aksonov/react-native-router-flux/issues/3241) +- There is no route defined for key when using Actions.reset\(\); [\#3234](https://github.com/aksonov/react-native-router-flux/issues/3234) +- Proposal: RNRF 3.5 [\#3213](https://github.com/aksonov/react-native-router-flux/issues/3213) - How to pass the props in Tabs? [\#3203](https://github.com/aksonov/react-native-router-flux/issues/3203) +- Navigation breaks after 4.0.0-beta.23 [\#3202](https://github.com/aksonov/react-native-router-flux/issues/3202) - How can I hear the event come back? [\#3201](https://github.com/aksonov/react-native-router-flux/issues/3201) - Upgrading from `4.0.0-beta27` to `4.0.0` breaks app [\#3198](https://github.com/aksonov/react-native-router-flux/issues/3198) - Unable to transfer a state value from one scene to another via “Actions.push\(\)” ... [\#3196](https://github.com/aksonov/react-native-router-flux/issues/3196) @@ -14,7 +31,7 @@ - drawer position right not working correctly [\#3180](https://github.com/aksonov/react-native-router-flux/issues/3180) - How to listen onback, onpop inside screen component [\#3178](https://github.com/aksonov/react-native-router-flux/issues/3178) - TextInput field lost focus for each character input [\#3177](https://github.com/aksonov/react-native-router-flux/issues/3177) -- \[Important\] Unable to use , RNRF getting error : bug of REACT file an issue [\#3174](https://github.com/aksonov/react-native-router-flux/issues/3174) +- ReactNativeJS: TypeError: undefined is not an object \(evaluating 'context.changedBits'\) [\#3174](https://github.com/aksonov/react-native-router-flux/issues/3174) - android back button move the app to forground mode [\#3173](https://github.com/aksonov/react-native-router-flux/issues/3173) - -v [\#3167](https://github.com/aksonov/react-native-router-flux/issues/3167) - currentScene is not showing the currently mounted screens key [\#3165](https://github.com/aksonov/react-native-router-flux/issues/3165) @@ -23,6 +40,10 @@ **Merged pull requests:** +- Add more information to issue template to help figure out cause of problems [\#3239](https://github.com/aksonov/react-native-router-flux/pull/3239) ([daviscabral](https://github.com/daviscabral)) +- Add title to StackProps type definition [\#3228](https://github.com/aksonov/react-native-router-flux/pull/3228) ([vanb](https://github.com/vanb)) +- Add support for deprecated Tabs component [\#3214](https://github.com/aksonov/react-native-router-flux/pull/3214) ([daviscabral](https://github.com/daviscabral)) +- 4.0.2-dev and CHANGELOG update [\#3211](https://github.com/aksonov/react-native-router-flux/pull/3211) ([daviscabral](https://github.com/daviscabral)) - Add 'ReduxExample' to .npmignore [\#3210](https://github.com/aksonov/react-native-router-flux/pull/3210) ([dextermb](https://github.com/dextermb)) - hotfix: Example, ReduxExample and depencies fixes for Android [\#3195](https://github.com/aksonov/react-native-router-flux/pull/3195) ([daviscabral](https://github.com/daviscabral)) - Added indicatorStyle to 'Tabs' props. [\#3192](https://github.com/aksonov/react-native-router-flux/pull/3192) ([AkshatGiri](https://github.com/AkshatGiri)) @@ -245,7 +266,6 @@ - popTo causes an infinite loop when route is not found [\#3026](https://github.com/aksonov/react-native-router-flux/issues/3026) - \[react-native-router-flux v4.0.0-beta.27/npm module\]PopTo method is not fixed [\#2799](https://github.com/aksonov/react-native-router-flux/issues/2799) -- \[Android\] rightTitle text cut issue [\#2696](https://github.com/aksonov/react-native-router-flux/issues/2696) **Closed issues:** @@ -295,7 +315,6 @@ - can i use v3 with latest react native \(55\)and react\(16.3\) [\#3037](https://github.com/aksonov/react-native-router-flux/issues/3037) - \[question\] popN\(...\) functionality? [\#3036](https://github.com/aksonov/react-native-router-flux/issues/3036) - TypeError:undefined is not a function \(evaluating 'addListener'\) [\#3033](https://github.com/aksonov/react-native-router-flux/issues/3033) -- How ro refresh drawer when I use actions \(of any file\) [\#3031](https://github.com/aksonov/react-native-router-flux/issues/3031) - Standalone TabBar by passing navigation props doesnt work [\#3030](https://github.com/aksonov/react-native-router-flux/issues/3030) - xcode can't be installed [\#3027](https://github.com/aksonov/react-native-router-flux/issues/3027) - Error: There is no route for key home . must be one of drawer [\#3024](https://github.com/aksonov/react-native-router-flux/issues/3024) @@ -389,7 +408,6 @@ - Undefined is not a function \(evaluating 'addListener'\) [\#2897](https://github.com/aksonov/react-native-router-flux/issues/2897) - Problem: All tabs setting same title & One navigation bar for all tabs [\#2895](https://github.com/aksonov/react-native-router-flux/issues/2895) - Support `showIcon` property for Scene Tabs [\#2892](https://github.com/aksonov/react-native-router-flux/issues/2892) -- Actions.key not working with onPress - Android [\#2890](https://github.com/aksonov/react-native-router-flux/issues/2890) - Router doesn't get rendered on screen - Android [\#2889](https://github.com/aksonov/react-native-router-flux/issues/2889) - Drawer close error [\#2887](https://github.com/aksonov/react-native-router-flux/issues/2887) - Jump to screen with no animation [\#2879](https://github.com/aksonov/react-native-router-flux/issues/2879) @@ -434,7 +452,6 @@ - Help With Drawer Menu [\#2793](https://github.com/aksonov/react-native-router-flux/issues/2793) - Unable to pass function as a prop down to scene [\#2790](https://github.com/aksonov/react-native-router-flux/issues/2790) - Duplicate scenes when using stack within stack [\#2784](https://github.com/aksonov/react-native-router-flux/issues/2784) -- Second time login and tabs throws me out of the app. [\#2783](https://github.com/aksonov/react-native-router-flux/issues/2783) - How to import CardStackStyleInterpolator from router flux. [\#2781](https://github.com/aksonov/react-native-router-flux/issues/2781) - Can someone show we an example how i can change the Animation while navigating. [\#2780](https://github.com/aksonov/react-native-router-flux/issues/2780) - undefined is not a function \(evaluating '\_reactNativeRouterFlux.Actions.guideHomePage\(\)'\) \_onPress [\#2779](https://github.com/aksonov/react-native-router-flux/issues/2779) @@ -494,15 +511,6 @@ - How do I keep the tab bar visible? [\#2726](https://github.com/aksonov/react-native-router-flux/issues/2726) - Error resetting scene: There is no route defined for key sceneName. [\#2724](https://github.com/aksonov/react-native-router-flux/issues/2724) - TypeError: undefined is not an object \(evaluating 'route.routeName'\) [\#2718](https://github.com/aksonov/react-native-router-flux/issues/2718) -- \[BUG\] Actions.popTo crashes navigation on v4 [\#2712](https://github.com/aksonov/react-native-router-flux/issues/2712) -- \[Drawer Issue\] Weird White Flash on Initial Start [\#2711](https://github.com/aksonov/react-native-router-flux/issues/2711) -- translucent Navbar on ios [\#2707](https://github.com/aksonov/react-native-router-flux/issues/2707) -- navTransparent doesn't work in Router\>Scene [\#2704](https://github.com/aksonov/react-native-router-flux/issues/2704) -- undefined is not an object state.children [\#2701](https://github.com/aksonov/react-native-router-flux/issues/2701) -- Avoid two nav bars when navigate from tabs Scene to another Scene [\#2694](https://github.com/aksonov/react-native-router-flux/issues/2694) -- Swipe Back Gesture does not works on Right To Left Layout \(iOS\) [\#2693](https://github.com/aksonov/react-native-router-flux/issues/2693) -- Gradually change the StatusBar color from one color to another when swiping through tabs [\#2690](https://github.com/aksonov/react-native-router-flux/issues/2690) -- tabBarPosition="top" bug [\#2687](https://github.com/aksonov/react-native-router-flux/issues/2687) **Merged pull requests:** @@ -523,33 +531,12 @@ - Exist app when clicked back on home screen [\#2725](https://github.com/aksonov/react-native-router-flux/issues/2725) - Content Component returns this error :TypeError: undefined is not an object \(evaluating 'route.routeName'\) in beta 22 but works in beat21 [\#2723](https://github.com/aksonov/react-native-router-flux/issues/2723) - undefined is not an object \(evaluating 'route.routeName'\) [\#2720](https://github.com/aksonov/react-native-router-flux/issues/2720) -- Example can't work for iOS11.2 [\#2717](https://github.com/aksonov/react-native-router-flux/issues/2717) -- Why do I have two headers when I go back [\#2716](https://github.com/aksonov/react-native-router-flux/issues/2716) -- Tabs Dynamic / Conditional Scene rendering [\#2715](https://github.com/aksonov/react-native-router-flux/issues/2715) -- DefaultRenderer in v4 [\#2710](https://github.com/aksonov/react-native-router-flux/issues/2710) -- How to set up a scene handoff animation separately [\#2709](https://github.com/aksonov/react-native-router-flux/issues/2709) -- How to pass props to a tab children [\#2708](https://github.com/aksonov/react-native-router-flux/issues/2708) -- onBack not working on any scenes [\#2706](https://github.com/aksonov/react-native-router-flux/issues/2706) -- Subviews not visible when adding Router in Android [\#2705](https://github.com/aksonov/react-native-router-flux/issues/2705) -- How to pass value to two tabs? [\#2703](https://github.com/aksonov/react-native-router-flux/issues/2703) -- \ doesnt work for me [\#2702](https://github.com/aksonov/react-native-router-flux/issues/2702) -- how to use Actions Binding in ListView [\#2700](https://github.com/aksonov/react-native-router-flux/issues/2700) -- Rendering tabs based on authentication and user roles [\#2699](https://github.com/aksonov/react-native-router-flux/issues/2699) -- When application opens from notification throws Error: There is not route defined... [\#2697](https://github.com/aksonov/react-native-router-flux/issues/2697) -- renderRightButton and renderLeftButton on Actions.refresh not working [\#2692](https://github.com/aksonov/react-native-router-flux/issues/2692) -- How to pop or go to another scene without transition. [\#2689](https://github.com/aksonov/react-native-router-flux/issues/2689) -- Navigating from home to another scene, suddenly reverts [\#2688](https://github.com/aksonov/react-native-router-flux/issues/2688) -- onPress Event for Scene Title [\#2686](https://github.com/aksonov/react-native-router-flux/issues/2686) **Merged pull requests:** - Drawer fixed, faulty closeDrawer removed, androidBack support added [\#2745](https://github.com/aksonov/react-native-router-flux/pull/2745) ([vibhavagarwal5](https://github.com/vibhavagarwal5)) - Fix wrong logic when back pressed [\#2735](https://github.com/aksonov/react-native-router-flux/pull/2735) ([wsxyeah](https://github.com/wsxyeah)) - Update license field in package.json to match LICENSE file [\#2721](https://github.com/aksonov/react-native-router-flux/pull/2721) ([andrew](https://github.com/andrew)) -- Update API.md [\#2714](https://github.com/aksonov/react-native-router-flux/pull/2714) ([linkstrifer](https://github.com/linkstrifer)) -- Update API.md [\#2698](https://github.com/aksonov/react-native-router-flux/pull/2698) ([tariksahni](https://github.com/tariksahni)) -- Adds panHandlers to wrapping scene in tabs example [\#2695](https://github.com/aksonov/react-native-router-flux/pull/2695) ([asciifaceman](https://github.com/asciifaceman)) -- Update tabBarOnPress handler to use react-navigation beta.20 contract [\#2691](https://github.com/aksonov/react-native-router-flux/pull/2691) ([rsailor](https://github.com/rsailor)) ## [4.0.0-beta.24](https://github.com/aksonov/react-native-router-flux/tree/4.0.0-beta.24) (2017-11-14) [Full Changelog](https://github.com/aksonov/react-native-router-flux/compare/4.0.0-beta.23...4.0.0-beta.24) From a8428d9e788acfd050a22dcbd798c1dcfc884f66 Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Thu, 6 Sep 2018 13:49:07 -0300 Subject: [PATCH 5/6] I guess thats it... --- Example/Example.js | 6 +-- Example/components/Home.js | 1 + Example/components/Login2.js | 7 --- Example/components/Login3.js | 5 ++ Example/components/Register.js | 2 +- Example/components/TabView.js | 13 ++++- src/navigationStore.js | 87 ++++++++++++++++------------------ 7 files changed, 62 insertions(+), 59 deletions(-) diff --git a/Example/Example.js b/Example/Example.js index 14fb8f712..d230908c6 100644 --- a/Example/Example.js +++ b/Example/Example.js @@ -130,9 +130,9 @@ const Example = () => ( - console.log('onExit')} leftTitle="Cancel" onLeft={Actions.pop} /> - - + console.log('Login: onExit')} leftTitle="Cancel" onLeft={Actions.pop} /> + console.log('Login2: onEnter') } backTitle="Back" panHandlers={null} duration={1} /> + console.log('Login3: onEnter') } onExit={() => console.log('Login3: onExit')} panHandlers={null} duration={1} /> diff --git a/Example/components/Home.js b/Example/components/Home.js index c5769bebe..328d6fca0 100644 --- a/Example/components/Home.js +++ b/Example/components/Home.js @@ -27,6 +27,7 @@ class Home extends React.Component { return ( Replace screen + Prop from dynamic method: {this.props.homeProp} ); diff --git a/Example/components/Login2.js b/Example/components/Login2.js index 1d23be9c7..c57c4a513 100644 --- a/Example/components/Login2.js +++ b/Example/components/Login2.js @@ -21,13 +21,6 @@ export default class extends React.Component { Login page 2 Title: {title} Data: {data} - ); diff --git a/Example/components/Login3.js b/Example/components/Login3.js index 17fc3c769..1c0111d85 100644 --- a/Example/components/Login3.js +++ b/Example/components/Login3.js @@ -24,6 +24,10 @@ const popToLogin2 = () => { Actions.popTo('loginModal2'); }; +const popAndRefresh = () => { + Actions.pop({ refresh: { data: 'Data after pop', title: 'title after pop' }, key: null }); +} + export default class extends React.Component { render() { const title = this.props.title || 'No Title'; @@ -36,6 +40,7 @@ export default class extends React.Component { + ); diff --git a/Example/components/Register.js b/Example/components/Register.js index 729193595..2d4e52e0c 100644 --- a/Example/components/Register.js +++ b/Example/components/Register.js @@ -16,7 +16,7 @@ const Register = () => ( Register page - + ); diff --git a/Example/components/TabView.js b/Example/components/TabView.js index 39145924f..b33f5932f 100644 --- a/Example/components/TabView.js +++ b/Example/components/TabView.js @@ -27,12 +27,20 @@ const styles = StyleSheet.create({ }); class TabView extends React.Component { - state = { hideNavBar: false }; + state = { hideNavBar: false, hideTabBar: false }; toggleNavBar = () => { this.setState(prevState => ({ hideNavBar: !prevState.hideNavBar }), () => Actions.refresh({ hideNavBar: this.state.hideNavBar })); }; + toggleTabBar = () => { + this.setState(prevState => ({ hideTabBar: !prevState.hideTabBar }), () => { + Actions.refresh({ + hideTabBar: this.state.hideTabBar, + }, 'tab_2'); + }); + }; + render() { return ( @@ -94,6 +102,9 @@ class TabView extends React.Component { > Toggle NavBar + {this.props.name === 'tab_2_1' && ( + + )} ); } diff --git a/src/navigationStore.js b/src/navigationStore.js index e0deb537a..0e9bb1634 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -136,49 +136,49 @@ function createTabBarOptions({ } function createNavigationOptions(params) { const { - title, + back, backButtonImage, - navTransparent, + backButtonTextStyle, + backTitle, backToInitial, + component, + drawerIcon, + drawerImage, + drawerPosition, + getTitle, + headerStyle, + headerTitleStyle, + hideDrawerButton, hideNavBar, hideTabBar, - backTitle, - right, - rightButton, + icon, + init, left, leftButton, - navigationBarStyle, - headerStyle, + leftButtonImage, + leftButtonTextStyle, + leftTitle, + navBar, navBarButtonColor, - tabBarLabel, - tabBarIcon, - icon, - getTitle, - renderTitle, - panHandlers, + navigationBarStyle, navigationBarTitleImage, navigationBarTitleImageStyle, - component, - rightTitle, - leftTitle, - leftButtonTextStyle, - rightButtonTextStyle, - backButtonTextStyle, - headerTitleStyle, - titleStyle, - navBar, - onRight, + navTransparent, onLeft, - rightButtonImage, - leftButtonImage, - init, - back, + onRight, + panHandlers, renderBackButton, renderNavigationBar, - hideDrawerButton, - drawerIcon, - drawerImage, - drawerPosition, + renderTitle, + right, + rightButton, + rightButtonImage, + rightButtonTextStyle, + rightTitle, + tabBarIcon, + tabBarLabel, + title, + titleStyle, ...props } = params; const NavBar = renderNavigationBar || navBar; @@ -385,7 +385,7 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { // detect if the component is not functional stateless // not sure if Component can be string-defined ("div") here // may be there is a better way to detect stateless function component, but this should work - if (isStatelessComponent(Component)) { + if (!isStatelessComponent(Component)) { class Wrapped extends React.Component { static propTypes = { navigation: PropTypes.shape().isRequired, @@ -404,14 +404,6 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { if (this.ref && this.ref.onEnter) { this.ref.onEnter(navigation && navigation.state); } - // WIP - this.subs = []; - if (this.ref && this.ref.onWillFocus) { - this.subs.push(navigation.addListener('willFocus', this.ref.onWillFocus)); - } - if (this.ref && this.ref.onDidFocus) { - this.subs.push(navigation.addListener('didFocus', this.ref.onDidFocus)); - } } componentWillUnmount() { @@ -422,8 +414,6 @@ function createWrapper(Component, wrapBy, store: NavigationStore) { if (this.ref && this.ref.onExit) { this.ref.onExit(navigation && navigation.state); } - // WIP - this.subs.forEach(sub => sub.remove()); this.ref = null; } @@ -801,6 +791,7 @@ class NavigationStore { } else if (tabBarPosition !== 'top') { createTabNavigator = createBottomTabNavigator; } + return createTabNavigator(res, { lazy, tabBarComponent, @@ -896,19 +887,21 @@ class NavigationStore { this.dispatch(DrawerActions.toggleDrawer()); }; - refresh = (data) => { + refresh = (data, sceneKey = null) => { const params = filterParam(data); const { key } = getActiveState(this.state); - console.log('KEY', key); - this.dispatch(NavigationActions.setParams({ key, params })); + this.dispatch(NavigationActions.setParams({ + key: (sceneKey ? sceneKey : key), + params, + })); }; - pop = ({ timeout, ...params } = {}) => { + pop = ({ timeout, key, ...params } = {}) => { const res = filterParam(params); if (timeout) { setTimeout(() => this.pop(params), timeout); } else { - this.dispatch(NavigationActions.back()); + this.dispatch(NavigationActions.back({ key })); if (res.refresh) { this.refresh(res.refresh); } From d2eebbb1a1e1a5010787e231ae3cd69df0396a3f Mon Sep 17 00:00:00 2001 From: "Davis Z. Cabral" Date: Thu, 6 Sep 2018 13:53:44 -0300 Subject: [PATCH 6/6] Lint --- src/navigationStore.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/navigationStore.js b/src/navigationStore.js index 0e9bb1634..cefa41922 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -890,10 +890,12 @@ class NavigationStore { refresh = (data, sceneKey = null) => { const params = filterParam(data); const { key } = getActiveState(this.state); - this.dispatch(NavigationActions.setParams({ - key: (sceneKey ? sceneKey : key), - params, - })); + this.dispatch( + NavigationActions.setParams({ + key: sceneKey || key, + params, + }), + ); }; pop = ({ timeout, key, ...params } = {}) => {