-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.js
More file actions
43 lines (39 loc) · 1.06 KB
/
home.js
File metadata and controls
43 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* @flow weak */
import React from "react";
import { View, Platform, Text, Linking } from "react-native";
class Home extends React.Component {
static navigationOptions = {
title: "Home"
};
componentDidMount() {
if (Platform.OS === "android") {
Linking.getInitialURL().then(url => {
console.log('url is', url);
this.navigate(url);
});
} else {
Linking.addEventListener("url", this.handleOpenURL);
}
}
componentWillUnmount() {
Linking.removeEventListener("url", this.handleOpenURL);
}
handleOpenURL = event => {
console.log('event is', event);
this.navigate(event.url);
};
navigate = url => {
console.log('url is in navigate', url);
const { navigate } = this.props.navigation;
const route = url.replace(/.*?:\/\//g, '');
const id = route.match(/\/([^\/]+)\/?$/)[1];
const routeName = route.split("/")[0];
if (routeName === "deep") {
navigate("People", { id, name: "chris" });
}
};
render() {
return <Text>Hello from Home!</Text>;
}
}
export default Home;