Friday, 26 October 2018

ReactJS error Failed to compile 'define' is not defined

The application which I'm trying to compile is not compiling with the external jquery & its associated JS files. The moment I try to link those files to my HTML page in a ReactJS application, it throws me below errors.

Errors are :

'define' is not defined no-undef.

This error comes from the jquery.js file which is a external file by nature & the line which shows this error is :

if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['jquery'], factory);
}

There is a jquery.sticky.js file which upon adding I get these errors.

'jQuery' is not defined no-undef

'padding' is not defined no-undef

This error comes from below lines

 padding =  s.stickyElement.innerWidth() - s.stickyElement.width();

enter image description here

Basically, the point is that I'm trying to convert an HTML template to ReactJS template but I got stuck at adding the external JS files only which by default ReactJS compiles to see if are as per the standards. I am able to convert the entire theme to React except for the JS file setup. I need help in this.

Any suggestions are welcome :-)



from ReactJS error Failed to compile 'define' is not defined

No comments:

Post a Comment