javascript - react 热加载程序 3

标签 javascript reactjs react-hot-loader

我正在尝试新的 React Hot Loader 3我收到一条警告消息:

warning.js:44 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of AppContainer.

这是应用程序文件。怎么了?
Ps: 和example上写的一样
Ps2:问题不在 App 中,因为它在 if 语句之外的 render() 上呈现
Ps3:警告仅在浏览器尝试“热重载”时出现(当我对任何文件进行更改时)

import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import a11y  from 'react-a11y'
import Store from './stores/Store';
import App from './components/App/App';

const store = new Store();

if(process.env.NODE_ENV === 'development'){
  a11y(React);
}

render(
  <AppContainer
    component={App}
    props={{ store }}
  />,
  document.getElementById('root')
);

if (module.hot) {
  module.hot.accept('./components/App/App', () => {
    render(
      <AppContainer
        component={require('./components/App/App').default}
        props={{ store }}
      />,
      document.getElementById('root')
    );
  });
}

最佳答案

好的,问题出在我的 .babelrc 文件上。我有一些其他的插件,我已经删除了,并且可以正常工作:

{
  "presets": ["es2015-loose", "react", "stage-1"],

  "plugins": [
    "react-hot-loader/babel",
    "transform-decorators-legacy"
  ],
}

关于javascript - react 热加载程序 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36751530/

相关文章:

javascript - .on(click,function) 不适用于动态添加的内容

javascript - KineticJS afterFrame 不循环运行

reactjs - react 引用错误:unknown node of type "JSXSpreadChild" with constructor "Node"

webpack - 无法获得多应用程序 webpack 配置以与 react-hot-loader 一起使用

javascript - Adobe Edge 生成带叠加层的视频,在 ios 上播放无需全屏

reactjs - 如何从 Action Creator 访问 redux 存储?

javascript - 在 React-Native 中检测和处理慢速互联网连接

javascript - react-hot-loader 在 create-react-app 中的 styled-components css 发生变化后不更新

javascript - react 热加载器 : this component is not accepted by Hot Loader

javascript - 将 Promise.all 结果分配给对象属性