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

Enabling webpack hot module reloading? #118

Closed
stevenmusumeche opened this issue Jul 25, 2017 · 4 comments
Closed

Enabling webpack hot module reloading? #118

stevenmusumeche opened this issue Jul 25, 2017 · 4 comments

Comments

@stevenmusumeche
Copy link

I looked through previous issues and could not find an answer to this. I had hot module reloading working previous with the JS version of create-react-app. After converting it to typescript, everything works well except for hot module reloading. The reloading actually does happen, but any typescript React components are not updating unless I do a full page refresh.

Has anyone got this working with typescript?

@wmonk
Copy link
Owner

wmonk commented Aug 8, 2017

As this issue hasn't been updated for a while, I am going to close it. If there are any updates feel free to re-open and comment. 👍

@wmonk wmonk closed this as completed Aug 8, 2017
@stevenmusumeche
Copy link
Author

I understand. It's not resolved (HMR doesn't work), but there has been no comment or activity.

@alexwebbb
Copy link

alexwebbb commented Aug 12, 2017

howdy

As of Typescript 2.0 (https://tinyurl.com/j8xro5g)

Hot module namespace errors are easily resolved by running

yarn add @types/webpack
yarn add @types/webpack-env

or the equivalent

npm install @types/webpack --save
npm install @types/webpack-env --save

Perhaps this will resolve your issue? I was able to get it working with this style (https://tinyurl.com/y7gzcqqm) of hot module reloading.

My index.tsx

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './index.css';

const rootEl = document.getElementById('root') as HTMLElement;

ReactDOM.render(
    <App />,
    rootEl
);

if (module.hot) {
    module.hot.accept('./App', () => {
        const NextApp = require('./App').default;
        ReactDOM.render(
            <NextApp />,
            rootEl
        );
    });
}

registerServiceWorker();

@jcrben
Copy link

jcrben commented Nov 6, 2017

upstream work seems to be at facebook/create-react-app#2304

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

No branches or pull requests

4 participants