Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

enable webpack hmr #312

Closed
wants to merge 2 commits into from
Closed

enable webpack hmr #312

wants to merge 2 commits into from

Conversation

jokester
Copy link

With this patch, modifying App.tsx will not cause a full page reload.

@lookfirst
Copy link

Seems a bit typesafe overkill, no?

This works for me...

const renderApp = () => {
	ReactDOM.render(<App />, document.getElementById('root') as HTMLElement);
};

renderApp();

declare const module: { hot: any };
if (module.hot) {
	module.hot.accept(['./App'], () => {
		renderApp();
	});
}

@deftomat
Copy link

deftomat commented May 4, 2018

@jokester Well, there is one missing thing: state will be not preserved between HMRs.
To make it works, you need to add react-hot-loader as described here.

So, please consider updating a webpack.config.dev.js file to make it works as expected (with preserving the state)

Also, without this, Apollo dev tool will also lost state after first HRM and you cannot inspect a watched queries.

@wmonk
Copy link
Owner

wmonk commented May 10, 2018

Hi, thanks for your PR! I am of the opinion that we shouldn't deviate too much away from the original react-scripts package, and have always found hot reloading to be pretty flaky, with people experiencing a whole host of issues. For this reason, I will leave it to be implemented by people ejecting, rather than a core part of this project.

@wmonk wmonk closed this May 10, 2018
@quantuminformation
Copy link

oh, I was so hoping for a way to do HMR without ejecting.

@kenzanboo
Copy link

@lookfirst suggestion works great!

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

Successfully merging this pull request may close these issues.

6 participants