This project is useful, but how to use hot reload?
Just drop this into your index.tsx
if (module.hot) {
module.hot.accept();
}
@jaredpalmer Thank you. Simple and useful. But when hot reload start, component state will be set to default state, how to resolve this problem?
May be I should stackoverflow this problem first.
@jaredpalmer Unfortunately, this will cause a compilation error since the latest typings for node don't include a hot property on the NodeModule type.
Just add @types/webpack-env
@types/webpack-env
or you can use (module as any).hot.accept() @corydeppen
Maybe you're looking for this, since you mentioned losing state
Hot reload doesn't work for me. I have opened new issue.
https://github.com/Microsoft/TypeScript-React-Starter/issues/50
In index.tsx:
(module as any).hot.accept();
ReactDOM.render(
<App />,
document.getElementById('root') as HTMLElement
);
Most helpful comment
@types/webpack-env