D
D
DrWeyber2021-02-19 14:54:06
JavaScript
DrWeyber, 2021-02-19 14:54:06

How to inject React into Chrome Extension's content.js file?

Hello everyone, I ran into such a problem that I can’t embed React in the content.js file.
For those who do not know when creating a chrome extension, there is a popup, this is a window in the corner on the right, and content.js is a file that allows you to interact with the DOM.
What needs to be done to inject React into this file?

Code in content.js file and browser error

image.png
image.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DrWeyber, 2021-02-23
@DrWeyber

With the help of react-app-rewired, I changed entry points to files such as content.js, background.js, popup.html/js
You can find ready-made examples on the Internet

D
Daniil Vasilyev, 2021-02-19
@hello_my_name_is_dany

Through webpack or gulp, first build your React App, and then use the already received JS in content.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question