this.context.router undefined in IE10
See original GitHub issueWe’re currently running version 0.13.3 and are using the State Mixins to access .getParams()
throughout the our app. Specifically we are calling the method in componentDidMount
and componentWillReceiveProps
.
When running the app in IE10, we get the error Unable to get property 'getCurrentParams' of undefined or null reference
, which is being traced back to the getParams
method of the State
object:
I should also note that we’re using Webpack and the Babel loader.
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
this.context.router undefined in IE10 on extended class in 1.0 ...
I'm using ES6-Syntax and fail to access this.context.router, but only in IE10 and IE9. My code looks like this basePage.jsx export default class...
Read more >Why is my context.router undefined in my react component?
I have tried to bind this to the function in the constructor , but it still is undefined . Also, when I put...
Read more >spPageContextInfo.siteServerRelativeUrl is undefined
I ran into a similar issue, but it was caught during build as I am using CreateReactApp , and they have a check...
Read more >Is your Vue app not working in IE 11? Here's how to fix it.
The main reason why your Vue app is breaking in IE11 is because the browser does not support modern JavaScript syntax. By that...
Read more >Handling common JavaScript problems - MDN Web Docs
Expand the showHeroes scope — you can see from this that the heroes variable is undefined , indicating that accessing the members property...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I want to add that this is caused by Babel classes inheritance not entirely supported in IE<11, and can be fixed by adding an additional Babel transformer.
https://babeljs.io/docs/advanced/caveats/#classes-10-and-below-
To summarize:
getParams()
Defining
contextTypes
appeared to have fixed any issues in IE10 for @coryvirok. However, it did not work for me. Instead I had to implement the params through the RouteHandler props as outlined in the docs (https://github.com/rackt/react-router/blob/v0.13.3/docs/guides/overview.md#dynamic-segments):isActive()
If you are using this method and need compatibility in IE10, you will need to implement a custom method to handle this. I decided to create a Router Utils that housed this method:
Though it’s not the best fix, it did resolve any issues with IE10. The downside to this approach is you don’t have access to the route names. Instead you have to target parts of the url. This isn’t a big issue for me since my route names and paths are consistent. An added bonus to this approach is I can check if a child route belongs to a parent route by passing in the parent route path:
I haven’t tested other methods that utilize
this.context.router
, but I’m assuming you’ll run into similar issues in IE10.