Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot loading loses effect after modifying the window.fetch method. #13443

Open
renzhaoz opened this issue Nov 1, 2023 · 0 comments
Open

Hot loading loses effect after modifying the window.fetch method. #13443

renzhaoz opened this issue Nov 1, 2023 · 0 comments

Comments

@renzhaoz
Copy link

renzhaoz commented Nov 1, 2023

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:)

  1. npm install create-react-app -g
  2. npx create-react-app myapp
  3. 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;
}

  1. 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant