You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReactfrom'react';importReactDOMfrom'react-dom';importPropTypesfrom'prop-types';import{BrowserRouterasRouter}from'react-router-dom';classAppextendsReact.Component{staticcontextTypes: React.ValidationMap<any>={router: PropTypes.shape({history: PropTypes.shape({push: PropTypes.func.isRequired,createHref: PropTypes.func.isRequired}).isRequired}).isRequired}constructor(...args){super(...args);// this will log "[{},{}]"console.log(JSON.stringify(args));// this will log "{}"console.log(JSON.stringify(this.context));}publicrender(){return(<p>Router {this.context.router ? 'defined' : 'is not defined'}</p>);}}// Wrap the `App` in the `Router` so that it provides it the `router` as contextReactDOM.render(<Router><App/></Router>,document.getElementById('root'));
Steps to reproduce
Attempt to render the above page and observe that the router in not defined.
Expected Behavior
this.context.router to be defined.
Actual Behavior
this.context.router is not defined, which also causes warnings due to the contextTypes expecting it.
The exact same code works with react-router-dom 4.3.1.
The text was updated successfully, but these errors were encountered:
Version
5.0.0 (with React 16.8.5)
Test Case
TypeScript code:
Steps to reproduce
Attempt to render the above page and observe that the router in not defined.
Expected Behavior
this.context.router
to be defined.Actual Behavior
this.context.router
is not defined, which also causes warnings due to thecontextTypes
expecting it.The exact same code works with
react-router-dom
4.3.1.The text was updated successfully, but these errors were encountered: