create-react-app: Hot Reload Fails, DOM adds an additional iframe containing entire contents of the html DOM element
Describe the bug
Everytime I save my code and hot reload happens, I am then unable to interact with the application (every component becomes unclickable). Upon further inspection of the DOM, I noticed that there was an iframe added within the document body which contains the entire HTML root, as well some various JS (see image below). If I remove this added iframe I am then able to interact with the application again (and hot reloads will work as normal following the removal).
There are no console errors, or warnings corresponding to this issue
Did you try recovering your dependencies?
Yes, I have tried removing all my dependency files multiple times, but still run into this issue. I am running yarn version 1.22.15 and this is within a project using yarn workspaces.
Which terms did you search for in User Guide?
Hot reload, iframe
Environment
current version of create-react-app: 4.0.3
running from /Users/-----/.config/yarn/global/node_modules/create-react-app
System:
OS: macOS 12.0.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node
Yarn: 1.22.15 - ~/.yarn/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.2/bin/npm
Browsers:
Chrome: 96.0.4664.110
Edge: Not Found
Firefox: Not Found
Safari: 15.1
npmPackages:
react: 17.0.2 (16.14.0)
react-dom: 17.0.2 (16.14.0)
react-scripts: 4.0.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
(Write your steps here:)
- Run
yarn start
and wait for application to load - Update the code on any component and hit ‘save’
- Try to interact with the application after hitting save
Expected behavior
Hot reload should work as expected and no iframe should be added, I should be able to interact with the application immediately
Actual behavior
Application becomes non-interactive, iframe is added to DOM
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 50
- Comments: 32
Links to this issue
Commits related to this issue
- fix: 優化 react-script 4 hot reload iframe 問題 (https://github.com/facebook/create-react-app/issues/11880) — committed to imagine10255/bear-react-grid by imagine10255 2 years ago
- downgrade react-error-overlay https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to pybricks/pybricks-code by dlech 2 years ago
- Remove process undefined error - https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to hc-institute-japan/kizuna by gopezella 2 years ago
- get rid of annoying iframe during dev mode see https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to cazlo/resume-andrew-paettie by cazlo 2 years ago
- get rid of annoying iframe during dev mode see https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to cazlo/resume-andrew-paettie by cazlo 2 years ago
- fix: react-scripts iframe injection iframe was being injected randomly b/c of react-scripts see facebook/create-react-app#11880 — committed to Lily-Technologies/lily-wallet by KayBeSee 2 years ago
- Fix create-react-app hot reload iframe issue Installed react-error-overlay 6.0.9 version Reference: https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to s2vt/blockchain-explorer by ChangHyun-ssvt 2 years ago
- Fix create-react-app hot reload iframe issue Installed react-error-overlay 6.0.9 version Reference: https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614 — committed to s2vt/blockchain-explorer by ChangHyun-ssvt 2 years ago
- "address" much CRA/Node/NPM stupidity Since early last year, when CRA does a hot reload, its error overlay drops an iframe over the entire document, forcing a manual reload. The kludge of forcing an ... — committed to folded-ear/gobrennas-client by barneyb 2 years ago
I recently had this issue aswell. I did couple of things to make it work. You can try these aswell.
"resolutions": { "react-error-overlay": "6.0.9" },
Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.
Hope this helps!!
@jake-engel this issue shouldn’t have been closed. This has to be fixed internally and not by some workarounds
The solution of install react-error-overlay didn’t work for me and neither did the update to version 5 of react-scripts (the application doesn’t start correctly). The iframe keeps showing up every time I make a code change.
try this:
package.json
Didn’t work the below steps. Still there is iframe inside the dom.
This worked for me as well. The last note step is finally what did it. Thanks
If you are using Yarn 2, Yarn 3, or Yarn berry, you need to manually patch your
yarn.lock
file, since Yarn 2+ doesn’t obey theresolutions
property ofpackage.json
. Instructions can be found here.It’s working for me, but I need to reinstall react-error-overlay again… It’s really boring
For them who did not got this fixed with @kirannambiar12 solution, make sure the “resolutions” in package.json did it’s job.
package-lock.json
and search forreact-error-overlay
and check if any of the matches have version other than"6.0.9"
. If there are any, the “resolutions” section did not work.scripts
section,"preinstall": "npx npm-force-resolutions"
npm install
Now do step 1 again. This time all matches for
react-error-overlay
should have version"6.0.9"
. If they do, the fast refresh should work as expected.Worked for me! Thanks a bunch
Hi, for anyone still encountering the issue, updating react-scripts to the latest version, 5.0.1, as of now, fixed it for me.
"react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "5.0.1", "
Adding
react-error-overlay
todevDependencies
fixed it for me.I tried all of these and it didn’t work, but then I tried installing with yarn and that worked. npm doesn’t support resolutions so the instructions to
npm install
I believe were a mistake, they meant to runyarn
@EvaGarzonBeltran and whoever else is having “process not defined error”. If the steps outlined previously did not work for you (as it didn’t work for me), and you are using NPM, then you need to use “overrides” instead of “resolutions” within your package.json. Also, my npm version was below 8.3 and therefore the “overrides” field was not being read. So you’ll need to upgrade your npm to at least 8.3.
Then go ahead and follow the steps again outlined earlier in this thread (restart your docker container as well if applicable). I was able to figure this out from following this stackoverflow question.
If this still doesn’t fix it and you’ve completely reinstalled all your modules and package lock, then I would suggest upgrading to react scripts 5 since that also seems to solve the issue.
this does not work for me
@EvaGarzonBeltran @aldipee If nothing works out, I guess the one thing you can do is override the css and call it out as display none. But am not sure if this is the right thing to do.
have you been able to solve this? I have exact problem
@kirannambiar12 Also worked for me!
Also worked for me!
Worked for me , thanks a bunch.