Browse Source

Allow links to open if home is already focused

Arnaud Vergnet 4 years ago
parent
commit
a54493a23f
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      src/screens/HomeScreen.js

+ 7
- 1
src/screens/HomeScreen.js View File

@@ -77,7 +77,13 @@ class HomeScreen extends React.Component<Props> {
77 77
                 headerRight: this.getHeaderButton,
78 78
             });
79 79
         }
80
-        // TODO if already on home screen
80
+        // Handle link open when home is focused
81
+        this.props.navigation.addListener('state', this.handleNavigationParams);
82
+        // handle link open when home is not focused or created
83
+        this.handleNavigationParams();
84
+    };
85
+
86
+    handleNavigationParams = () => {
81 87
         if (this.props.route.params !== undefined) {
82 88
             if (this.props.route.params.shouldOpen !== undefined && this.props.route.params.shouldOpen) {
83 89
                 this.props.navigation.navigate(this.props.route.params.nextScreen, this.props.route.params.data);

Loading…
Cancel
Save