question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hot Module Replacement not working with React (reloads the page)

See original GitHub issue
  • Laravel Mix Version: 1.0.7
  • Node Version (node -v): v8.1.2
  • NPM Version (npm -v): 5.0.3
  • OS: Mac 10.12

Description:

Trying to enable this, however it reloads the page whenever the JS is recompiled. Is this supposed to work out of the box?

Steps To Reproduce:

  1. Clone https://github.com/morrislaptop/laravel54-react
  2. Run npm install
  3. Run npm run hot
  4. Load website in browswer
  5. Make a change to resources/assets/js/components/Example.js
  6. Observe browser reloads instead of HMR

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
xiomaicommented, Jul 24, 2017

I’ve had this issue before which was fixed by adding this lines at the end of my root react js file:

if (process.env.NODE_ENV === 'development') {
	if (module.hot) {
		module.hot.accept();
	}
}

it also works if I put it in resources/assets/js/app.js [Laravel 5.4 Environment]

0reactions
stale[bot]commented, Dec 4, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload is not working in my React App - Stack Overflow
Hot Reload is not working in my React App · This does happen sometimes. Do npm install and try adding some code. ·...
Read more >
Hot Reload stopped working with React "^17.0.1" · Issue #9904
I'm having trouble refreshing the app at all, adding or removing components does nothing, I have to manually refresh the page to get...
Read more >
Getting Started · React Hot Loader - Dan gaearon
Step 1 (of 3): Enabling Hot Module Replacement (HMR). HMR allows us to replace modules in-place without restarting the server. Here's how you...
Read more >
react-hot-loader - npm
Hot reloading code is just one line in the beginning and one line at the end of each module so you might not...
Read more >
Enabling hot reload in React web app | by Dong Chen - Medium
Hot reload allows developers to see result of code change in browser without page refresh. ... This is the most confusing part as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found