1

I am getting this error in IE 11 on Windows 10 TypeError: Object doesn't support property or method 'someMethod'. I am using React and calling a method named someMethod inside componentDidMount in Full.js file.

The someMethod method is defined outside src directory of react using jQuery externally (and not inside react like this import $ from jquery) using <script> tag in index.html. And I am accessing that method in my Full.js as follows:

componentDidMount() {
   window.someMethod();
}

And that's the place I am getting the error in IE 11 and the above code is working fine in Chrome, Firefox and even in Edge but not in IE 11. I tried hitting window in the console of IE but I couldn't find someMethod but it is showing in Firefox's and Chrome's console.

The someMethod method is defined inside a file named methods.js in code directory outside of src directory and I am getting the same error when calling other methods defined in this file in the following manner:

function someMethod() {
    // Some code here
}

Is this is a problem with IE regarding Javascript Hoisting?

PS: I have core-js polyfill installed in my project and I also tried declaring the someMethod method I the following manner as well but still no luck:

var someMethod = function() {
    // Some Code here
}
Vibhor
  • 535
  • 4
  • 14
  • 1
    Is the function *really* called "someMethod" or is there another name? IE protects many global symbols. – Pointy Jul 01 '18 at 13:11
  • 1
    The name is different I just used someMethod for demo purpose. – Vibhor Jul 01 '18 at 13:13
  • OK, well what is the real name of the function? The name itself could explain the problem. Have you tried changing the name to literally "someMethod" to see if that affects things? – Pointy Jul 01 '18 at 13:16
  • 1
    It has anything to do with the name of the function. I tried changing the name of the function but still got the same error with the newly changed function name. – Vibhor Jul 01 '18 at 14:08

0 Answers0