Unverified Commit db5b3dc8 authored by Luis Fernando Alvarez D's avatar Luis Fernando Alvarez D Committed by GitHub

Update types for with-router (#7106)

* Updated declarations for with-router
parent baabfbd7
import React from 'react'
import PropTypes from 'prop-types'
import { NextComponentType, IContext } from 'next-server/dist/lib/utils'
import { IPublicRouterInstance } from './router';
export default function withRouter(ComposedComponent: React.ComponentType<any> & {getInitialProps?: any}) {
class WithRouteWrapper extends React.Component {
export type WithRouterProps = {
router: IPublicRouterInstance,
}
export type ExcludeRouterProps<P> = Pick<P, Exclude<keyof P, keyof WithRouterProps>>
export default function withRouter<P extends WithRouterProps, C = IContext>(ComposedComponent: NextComponentType<C, any, P>): React.ComponentClass<ExcludeRouterProps<P>> {
class WithRouteWrapper extends React.Component<ExcludeRouterProps<P>> {
static displayName?: string
static getInitialProps?: any
static contextTypes = {
router: PropTypes.object,
}
context!: WithRouterProps
render() {
return <ComposedComponent
router={this.context.router}
{...this.props}
{...this.props as any}
/>
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment