Can't get Webpack 2 HMR React to work

后端 未结 2 768
鱼传尺愫
鱼传尺愫 2020-12-21 06:09

Currently I\'m struggling to get HMR working in my Webpack 2 setup. I\'ll explain my entire setup so I hope this is enough for someone to understand what\'s happening.

2条回答
  •  时光取名叫无心
    2020-12-21 07:01

    Check this issue on GitHub or just use this in your index.js:

    import React from 'react'
    import ReactDOM from 'react-dom'
    import { AppContainer } from 'react-hot-loader'
    
    import App from './components/App'
    
    const render = Component => { 
        ReactDOM.render(
            
                
            ,
            document.getElementById('react-root')
        )
    }
    
    render(App)
    
    if(module.hot) {
        module.hot.accept();
    }
    

提交回复
热议问题