Skip to content

Commit

Permalink
[state-router] Import * triggers a deprecation warning, so use import…
Browse files Browse the repository at this point in the history
… type instead
  • Loading branch information
bjoerge committed Sep 14, 2017
1 parent 34cdb2e commit 37b8951
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions packages/@sanity/state-router/src/components/IntentLink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import * as React from 'react'
import React from 'react'
import type {Node} from 'react'
import Link from './Link'
import type {RouterProviderContext} from './types'
import internalRouterContextTypeCheck from './internalRouterContextTypeCheck'
Expand All @@ -8,7 +9,7 @@ export default class IntentLink extends React.PureComponent<*, *> {
props: {
intent: string,
params?: Object,
children: React.Node,
children: Node,
className: string
};

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/state-router/src/components/Link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import * as React from 'react'
import React from 'react'
import {omit} from 'lodash'
import type {RouterProviderContext} from './types'
import internalRouterContextTypeCheck from './internalRouterContextTypeCheck'
Expand Down
5 changes: 3 additions & 2 deletions packages/@sanity/state-router/src/components/RouteScope.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// @flow
import PropTypes from 'prop-types'
import * as React from 'react'
import React from 'react'
import isEmpty from '../utils/isEmpty'

import type {Node} from 'react'
import type {RouterProviderContext, NavigateOptions, InternalRouter} from './types'

function addScope(routerState: Object, scope: string, scopedState: Object) {
Expand All @@ -14,7 +15,7 @@ function addScope(routerState: Object, scope: string, scopedState: Object) {

type Props = {
scope: string,
children: React.Node
children: Node
}

export default class RouteScope extends React.Component<*, *> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// @flow
import * as React from 'react'
import React from 'react'
import PropTypes from 'prop-types'
import pubsub from 'nano-pubsub'
import type {Node} from 'react'
import type {Router} from '../types'
import type {RouterProviderContext, NavigateOptions, InternalRouter, RouterState} from './types'
import pubsub from 'nano-pubsub'

type Props = {
onNavigate: (nextPath: string, options?: NavigateOptions) => void,
router: Router,
state: RouterState,
children: React.Node
children: Node
}

export default class RouterProvider extends React.Component<*, *> {
Expand Down
7 changes: 4 additions & 3 deletions packages/@sanity/state-router/src/components/WithRouter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// @flow
import * as React from 'react'
import type {Router} from './types'
import React from 'react'
import withRouterHOC from './withRouterHOC'
import type {Router} from './types'
import type {Node} from 'react'

type Props = {
router: Router,
children: (Router) => React.Node
children: (Router) => Node
}

const WithRouter = withRouterHOC((props: Props) => props.children(props.router))
Expand Down
7 changes: 4 additions & 3 deletions packages/@sanity/state-router/src/components/withRouterHOC.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow
import * as React from 'react'
import type {Router, InternalRouter} from './types'
import React from 'react'
import internalRouterContextTypeCheck from './internalRouterContextTypeCheck'
import type {Router, InternalRouter} from './types'
import type {ComponentType} from 'react'

type State = {
routerState: Object
Expand All @@ -17,7 +18,7 @@ const NO_CONTEXT_STATE = {
}
}

export default function withRouter<Props: {}>(Component: React.ComponentType<{ router: Router } & Props>): React.ComponentType<Props> {
export default function withRouter<Props: {}>(Component: ComponentType<{ router: Router } & Props>): ComponentType<Props> {

return class extends React.Component<*, *> {
static displayName = `withRouter(${Component.displayName || Component.name})`
Expand Down

0 comments on commit 37b8951

Please sign in to comment.