M
M
Max Kazanovsky2020-07-26 14:40:11
JavaScript
Max Kazanovsky, 2020-07-26 14:40:11

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 '<'


For a very long time I can not solve this problem.

I would really appreciate your help, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Kostenko, 2020-07-27
@ktim8168

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 question

Ask a Question

731 491 924 answers to any question