@@ -25,19 +25,23 @@ class App extends React.Component {
25
25
BackHandler . addEventListener ( 'hardwareBackPress' , this . props . backAndroidHandler || this . onBackPress ) ;
26
26
27
27
// If the app was "woken up" by an external route.
28
- Linking . getInitialURL ( ) . then ( url => this . parseDeepURL ( url ) ) ;
28
+ Linking . getInitialURL ( ) . then ( ( url ) => this . parseDeepURL ( url ) ) ;
29
29
// Add an event listener for further deep linking.
30
- Linking . addEventListener ( 'url' , this . handleDeepURL ) ;
30
+ this . subscription = Linking . addEventListener ( 'url' , this . handleDeepURL ) ;
31
31
}
32
32
33
33
componentWillUnmount ( ) {
34
34
BackHandler . removeEventListener ( 'hardwareBackPress' , this . props . backAndroidHandler || this . onBackPress ) ;
35
- Linking . removeEventListener ( 'url' , this . handleDeepURL ) ;
35
+ if ( typeof Linking . removeEventListener === 'function' ) {
36
+ Linking . removeEventListener ( 'url' , this . handleDeepURL ) ;
37
+ } else if ( this . subscription !== null ) {
38
+ this . subscription . remove ( ) ;
39
+ }
36
40
}
37
41
38
42
onBackPress = ( ) => this . props . navigationStore . pop ( ) ;
39
43
40
- handleDeepURL = e => this . parseDeepURL ( e . url ) ;
44
+ handleDeepURL = ( e ) => this . parseDeepURL ( e . url ) ;
41
45
42
46
parseDeepURL = ( url ) => {
43
47
// If there is no url, then return.
@@ -53,8 +57,8 @@ class App extends React.Component {
53
57
}
54
58
// Build an array of paths for every scene.
55
59
const allPaths = Object . values ( this . props . navigationStore . states )
56
- . map ( obj => obj . path )
57
- . filter ( path => path ) ;
60
+ . map ( ( obj ) => obj . path )
61
+ . filter ( ( path ) => path ) ;
58
62
// Try to match the url against the set of paths and parse the url parameters.
59
63
const parsedPath = pathParser ( cleanUrl , allPaths ) ;
60
64
@@ -70,7 +74,7 @@ class App extends React.Component {
70
74
const actionKey = Object . entries ( this . props . navigationStore . states )
71
75
. filter ( ( [ , value ] ) => value . path === path )
72
76
. map ( ( [ key ] ) => key )
73
- . find ( key => key ) ;
77
+ . find ( ( key ) => key ) ;
74
78
75
79
if ( this . props . onDeepLink ) {
76
80
this . props . onDeepLink ( { url, action : actionKey , params } ) ;
@@ -81,9 +85,7 @@ class App extends React.Component {
81
85
} ;
82
86
83
87
render ( ) {
84
- const {
85
- dispatch, state, navigator : AppNavigator , navigationStore,
86
- } = this . props ;
88
+ const { dispatch, state, navigator : AppNavigator , navigationStore } = this . props ;
87
89
if ( dispatch && state ) {
88
90
navigationStore . externalDispatch = dispatch ;
89
91
navigationStore . externalState = state ;
@@ -108,9 +110,7 @@ class App extends React.Component {
108
110
}
109
111
}
110
112
111
- const Router = ( {
112
- createReducer, sceneStyle, onStateChange, scenes, uriPrefix, navigator, getSceneStyle, children, onDeepLink, wrapBy, navigationStore : store , ...props
113
- } ) => {
113
+ const Router = ( { createReducer, sceneStyle, onStateChange, scenes, uriPrefix, navigator, getSceneStyle, children, onDeepLink, wrapBy, navigationStore : store , ...props } ) => {
114
114
const data = { ...props } ;
115
115
if ( getSceneStyle ) {
116
116
data . cardStyle = getSceneStyle ( props ) ;
@@ -143,7 +143,7 @@ Router.defaultProps = {
143
143
onStateChange : null ,
144
144
scenes : null ,
145
145
navigator : null ,
146
- wrapBy : props => props ,
146
+ wrapBy : ( props ) => props ,
147
147
getSceneStyle : null ,
148
148
sceneStyle : null ,
149
149
children : null ,
0 commit comments