Create-react-app: Getting '$' is not defined no-undef when trying to use jquery

Created on 8 May 2018  路  1Comment  路  Source: facebook/create-react-app

I want to use jquery in my react app, but I keep getting this error :
'$' is not defined no-undef

I searched the issues but not one seems to specifically add jquery as a cdn in index.html.

I tried using this :
https://www.npmjs.com/package/eslint-config-react-app

Here is my .eslintrc file :

{
    "extends": "react-app",
    "env": {
        "jquery": true
    }   
}

I don't want to import it, I really need it to work via index.html as a cdn

Any help with this would appreciated!

Most helpful comment

Put this at the top of your file:

const $ = window.$;

Please check out the documentation:

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables

>All comments

Put this at the top of your file:

const $ = window.$;

Please check out the documentation:

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables

Was this page helpful?
0 / 5 - 0 ratings