Describe the bug
Hot loading loses effect after modifying the window.fetch method.
Did you try recovering your dependencies?
(Write your answer here.)YES
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
windows
package info:
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
Steps to reproduce
(Write your steps here:)
- npm install create-react-app -g
- npx create-react-app myapp
- Add Authorization info to http request, then import this file in App.js, like this:
import CloudUtils from './CloudUtils';
const oldFetch = fetch;
const newFetch = (url, options) => {
const token = CloudUtils.getToken();
const headers = options.headers || new Headers();
headers.append('Authorization', `bearer ${token}`);
options.headers = headers;
return oldFetch(`${url}`, options);
};
if (window) {
window.fetch = newFetch;
window.oldFetch = oldFetch;
}
- Hot reload not work now!
Expected behavior
(Write what you thought would happen.)
Hot reload not work!
Actual behavior
(Write what happened. Please add screenshots!)
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Describe the bug
Hot loading loses effect after modifying the window.fetch method.
Did you try recovering your dependencies?
(Write your answer here.)YES
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
windows
package info:
Steps to reproduce
(Write your steps here:)
Expected behavior
(Write what you thought would happen.)
Hot reload not work!
Actual behavior
(Write what happened. Please add screenshots!)
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)