0

按照这里的教程一步一步设置了
https://blog.csdn.net/huangpb123/article/details/78556652
发现最终没什么效果,且报警告
react-🔥-dom patch is not detected. React 16.6+ features may not work.

最终按照这里的也解决了警告,https://segmentfault.com/q/1010000020161653/
下载@hot-loader/react-dom,在配置alias,最终仍然没有热更新的效果,折腾一天了,搞不懂,react搭个项目热更新这么难吗

贴上代码

// import 'babel-polyfill'
import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter } from 'react-router-dom';
import routers from './route/routes'
import { Modal, ConfigProvider } from 'antd';
import { PermissionContext } from '@constant/context'
import zh_CN from 'antd/es/locale/zh_CN.js';
import '../stylesheet/global.less'
import { hot } from 'react-hot-loader';
// import { AppContainer } from 'react-hot-loader';


class Application extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
     
    }
  }

  async componentDidMount() {
   
  }


  render() {
    return (
      <PermissionContext.Provider value={{ permissions: this.state.data, keepAlive: this.state.keepAlive }}>
        <HashRouter>
          <ConfigProvider locale={zh_CN}>
            <LayoutView onLogout={this.logout}>
              {routers}
            </LayoutView>
          </ConfigProvider>
        </HashRouter>
      </PermissionContext.Provider>
    )
  }
}

// Application = hot(module)(Application)

ReactDOM.render(
  <Application />
  ,
  document.getElementById('main')
);

试了一通,什么都不管用,真难啊

12月4日提问
1 个回答
0

已采纳

我知道了,这个破项目不是用的webpack-dev-server命令启动项目的,用的是webpack内置观察者模式watch,坑呀

撰写答案

推广链接