1
- import PropTypes from 'prop-types'
2
1
// @flow
3
- import React , { Element } from 'react' ;
2
+ import PropTypes from 'prop-types'
3
+ import * as React from 'react'
4
4
import isEmpty from '../utils/isEmpty'
5
5
6
6
import type { RouterProviderContext , NavigateOptions , InternalRouter } from './types'
7
7
8
- function addScope ( routerState : Object , scope : string , scopedState : Object ) {
8
+ function addScope ( routerState : Object , scope : string , scopedState : Object ) {
9
9
return scopedState && {
10
10
...routerState ,
11
11
[ scope ] : scopedState
@@ -14,18 +14,18 @@ function addScope(routerState : Object, scope : string, scopedState : Object) {
14
14
15
15
type Props = {
16
16
scope : string ,
17
- children : Element < * >
17
+ children : React . Node
18
18
}
19
19
20
- export default class RouteScope extends React . Component {
20
+ export default class RouteScope extends React . Component < * , * > {
21
21
props : Props
22
22
__internalRouter : InternalRouter
23
23
24
24
static childContextTypes = RouteScope . contextTypes = {
25
25
__internalRouter : PropTypes . object
26
26
}
27
27
28
- constructor ( props : Props , context : RouterProviderContext ) {
28
+ constructor ( props : Props , context : RouterProviderContext ) {
29
29
super ( )
30
30
const parentInternalRouter = context . __internalRouter
31
31
@@ -37,7 +37,7 @@ export default class RouteScope extends React.Component {
37
37
}
38
38
}
39
39
40
- getChildContext ( ) : RouterProviderContext {
40
+ getChildContext ( ) : RouterProviderContext {
41
41
return {
42
42
__internalRouter : this . __internalRouter
43
43
}
@@ -53,14 +53,14 @@ export default class RouteScope extends React.Component {
53
53
const parentInternalRouter = this . context . __internalRouter
54
54
const scope = this . props . scope
55
55
56
- const nextStateScoped : Object = isEmpty ( nextState )
56
+ const nextStateScoped : Object = isEmpty ( nextState )
57
57
? { }
58
58
: addScope ( parentInternalRouter . getState ( ) , scope , nextState )
59
59
60
60
return parentInternalRouter . resolvePathFromState ( nextStateScoped )
61
61
}
62
62
63
- navigate = ( nextState : Object , options ? : NavigateOptions ) : void => {
63
+ navigate = ( nextState : Object , options ? : NavigateOptions ) : void => {
64
64
const parentInternalRouter = this . context . __internalRouter
65
65
const nextScopedState = addScope ( parentInternalRouter . getState ( ) , this . props . scope , nextState )
66
66
parentInternalRouter . navigate ( nextScopedState , options )
0 commit comments