355078c350
Because Typescript output is turned to commonjs for these modules currently it’s better to do this. Also convert withRouter to typescript, making it smaller.
22 lines
549 B
TypeScript
22 lines
549 B
TypeScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
export default function withRouter(ComposedComponent: React.ComponentType<any> & {getInitialProps?: any}) {
|
|
class WithRouteWrapper extends React.Component {
|
|
static getInitialProps?: any
|
|
static contextTypes = {
|
|
router: PropTypes.object,
|
|
}
|
|
|
|
render() {
|
|
return <ComposedComponent
|
|
router={this.context.router}
|
|
{...this.props}
|
|
/>
|
|
}
|
|
}
|
|
|
|
WithRouteWrapper.getInitialProps = ComposedComponent.getInitialProps
|
|
|
|
return WithRouteWrapper
|
|
}
|