Changes in React source code not reflecting in build

Viewed 27

I've recently made my first react app and deployed it to firebase. I'm facing an issue with the code changes in the development region.

Problem Statement- When I first tried to build the app using the command "npm run build", the build went fine, but when I'm trying to make changes in the source code and then again using the build command to rebuild my app, the app is not showing the changes made.

Solutions I tried but didn't seem to work out for me-

  1. Restarting VS code.
  2. deleting the build folder and rebuilding it.
  3. deleting package.json.lock and rebuilding it.
1 Answers

Are you using create-react-app?

I've had the same issue due to the caching done by the service worker.

Referencing this: React app changes not updaiting after running npm run build

// import registerServiceWorker from './registerServiceWorker'; // comment this line
import { unregister } from './registerServiceWorker';
// registerServiceWorker() 
unregister();// add this

Just to be thorough, delete the build folder and package-lock.json as well.

Then npm run build again.

Related