Skip to content

Commit 92df62e

Browse files
committed
get webpack HMR working
1 parent 10e5dd0 commit 92df62e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

browser-react/src/index.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,26 @@ import App from './App';
44
import './index.css';
55
import registerServiceWorker from './registerServiceWorker';
66

7+
function registerHMR() {
8+
type ModuleHMR = typeof module & {
9+
hot?: {
10+
accept(dependencies: string | string[], callback: (updatedDependencies: any[]) => void): void
11+
}
12+
};
13+
14+
if ((module as ModuleHMR).hot) {
15+
(module as ModuleHMR).hot!.accept('./App', () => {
16+
ReactDOM.render(
17+
<App />,
18+
document.getElementById('root') as HTMLElement
19+
);
20+
});
21+
}
22+
}
23+
724
ReactDOM.render(
825
<App />,
926
document.getElementById('root') as HTMLElement
1027
);
1128
registerServiceWorker();
29+
registerHMR();

0 commit comments

Comments
 (0)