I am debugging my chrome extension pop page, and open it in uri : chrome-extension://keekhfjbmbpmlgpfljclblgbjchoencn/popup.html
This page is using reactjs, but the react devtools is not showing. Is it by design?
You can use React Dev Tools but you will have to use the standalone version to work in browser extension (because of CSP restrictions). Run this in your console
$ npm install -g react-devtools
and add this to you manifest.json
"content_security_policy": "connect-src ws://localhost:8097"
Now run react-devtools
Don't forget to reload your extension.
P.S.
If you don't want to install react-devtools
globally you can run npm install --save-dev react-devtools
from your project and then add to package.json
"scripts": {
"react-devtools": "react-devtools"
}
And run npm run react-devtools
The React Dev Tools needs to inject a content script in your page to check your react components. To do that they declare in their manifest the pattern that matches any url with a permitted scheme and these are (from the docs https://developer.chrome.com/extensions/match_patterns):
http, https, file, ftp
In other words: the React Developer Tools can not run in extension pages.
This is what I did to make it work with manifest v3:
npm i -D react-devtools
"react-devtools": "react-devtools"
to package.json
scriptsrender
: import 'react-devtools'
npm run react-devtools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With