Answer the question
In order to leave comments, you need to log in
How to include jQuery library in React js?
Greetings! Colleagues, I ran into a problem with importing a library from a file in React.
The crux of the problem:
There is a ready-made website that connects various js libraries through the HTML script tag. I just need to include the js - jQuery library in my project . What can be installed via npm / yarn I installed and imported, but one of the files is missing in the npm library (because there the layout designer assembled a bunch of libraries into one file).
I tried different React libraries to connect the script tag, but everything is useless in the console, I get something like this error:
Uncaught SyntaxError: Unexpected token '<'
Answer the question
In order to leave comments, you need to log in
Did you install jquery with yarn add jquery ? Then you can use it in the component you
want. If the problem is that jquery is not visible, try the following: in the root index.js file, import jquery right after 'react-dom'
import $ from 'jquery';
import 'jquery';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question