嵌套的React.createElement(...)调用中未定义组件引用

时间:2017-05-09 16:32:41

标签: reactjs typescript npm-install package.json

我已经使用了几个月没有问题的代码,但是在运行npm install并重新安装我的node_modules后,它已经停止工作。

import { Footer } from 'components/common';

....

  public render() {
    return (
      <Provider {...this.stores}>
        <div className="app">
          {this.props.children}
          <Footer />
          <DevTools />
        </div>
      </Provider>
    );
  }

变成......

_createClass(App, [{
    key: "render",
    value: function render() {
        return React.createElement(
            mobx_react_1.Provider,
            this.stores,
            React.createElement(
                "div",
                { className: "app" },
                this.props.children,
                React.createElement(common_1.Footer, null),
                React.createElement(mobx_react_devtools_1.default, null)
            )
        );
    }
}]);

common_1由于某种原因未定义,我无法弄清楚原因。

mobx_react_1.Provider不是,因此似乎只有嵌套组件受到影响。如果我添加“let myVariable =&lt; Footer /&gt;”在返回之前,它按预期工作(即使我从未在return语句中引用myVariable!)

我尝试过不同的组件,但总是会遇到同样的错误。我没有收到任何编译错误(除了“DeprecationWarning:loaderUtils.parseQuery()..”)并且我没有更改我的webpack.config。这些是我的package.json中的依赖项:

  "dependencies": {
    "@types/lodash": "4.14.55",
    "bootstrap": "4.0.0-alpha.6",
    "mobx": "3.1.2",
    "mobx-react": "4.1.1",
    "moment": "2.17.1",
    "react": "15.4.2",
    "react-bootstrap": "0.30.7",
    "react-breadcrumbs": "1.5.2",
    "react-datetime": "2.8.6",
    "react-dnd": "2.1.4",
    "react-dnd-html5-backend": "2.1.2",
    "react-dom": "15.4.1",
    "react-router": "3.0.0",
    "react-router-bootstrap": "0.23.1",
    "whatwg-fetch": "2.0.2"
  },
  "devDependencies": {
    "@types/react": "0.14.57",
    "@types/react-dom": "0.14.23",
    "@types/react-router": "2.0.48",
    "awesome-typescript-loader": "3.1.3",
    "babel-core": "6.21.0",
    "babel-loader": "6.2.10",
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-preset-es2015": "6.18.0",
    "babel-preset-react": "6.16.0",
    "babel-preset-stage-1": "6.22.0",
    "bootstrap-sass": "3.3.7",
    "css-loader": "0.26.1",
    "file-loader": "0.9.0",
    "html-webpack-plugin": "2.26.0",
    "image-webpack-loader": "3.3.0",
    "mobx-react-devtools": "4.2.11",
    "node-sass": "4.2.0",
    "react-hot-loader": "3.0.0-beta.2",
    "sass-loader": "4.1.1",
    "style-loader": "0.13.1",
    "typescript": "2.3.2",
    "url-loader": "0.5.7",
    "webpack": "2.5.1",
    "webpack-dev-server": "2.4.4"
  }

知道我在这里缺少什么吗?

0 个答案:

没有答案