Reactjs 未捕获类型错误:无法读取属性';安装组件';运行create react应用程序生成版本时出现未定义错误 复制步骤
我的createreact应用程序在开发模式下运行良好,但当我使用(npm run build)运行构建的应用程序时,它是一个空白页面,并且出现此控制台错误Reactjs 未捕获类型错误:无法读取属性';安装组件';运行create react应用程序生成版本时出现未定义错误 复制步骤,reactjs,webpack,react-router,react-redux,create-react-app,Reactjs,Webpack,React Router,React Redux,Create React App,我的createreact应用程序在开发模式下运行良好,但当我使用(npm run build)运行构建的应用程序时,它是一个空白页面,并且出现此控制台错误 Uncaught TypeError: Cannot read property 'mountComponent' of undefined at r (patchUtils.js:51) at e.exports (reactPatches.js:41) at react.js:59 at Object.r
Uncaught TypeError: Cannot read property 'mountComponent' of undefined
at r (patchUtils.js:51)
at e.exports (reactPatches.js:41)
at react.js:59
at Object.ready (reactInternals.js:24)
at r (react.js:58)
at Object.<anonymous> (index.js:12)
at t (bootstrap 3c1adc8fa04e423f7356:19)
at Object.<anonymous> (main.448e9d91.js:66458)
at t (bootstrap 3c1adc8fa04e423f7356:19)
at bootstrap 3c1adc8fa04e423f7356:62
at bootstrap 3c1adc8fa04e423f7356:62
下面是App.js
import React from "react";
import { Provider } from "react-redux";
import { BrowserRouter as Router, Switch } from "react-router-dom";
import PageLayoutRoute from "components/controls/PageLayoutRoute";
import { SocialIntegrator } from "components/Social";
import { createStore } from "store";
import routes from "components/routes";
import HomePage from "components/HomePage";
import StudioPage from "components/StudioPage";
import FramingPage from "components/FramingPage";
import OrderReviewPage from "components/OrderReviewPage";
import OrderConfirmationPage from "components/OrderConfirmationPage";
import { injectGlobal } from "styled-components";
injectGlobal`
html {
overflow-y: auto;
}
`;
const store = createStore();
const App = () =>
<SocialIntegrator>
<Provider store={store}>
<Router>
<Switch>
<PageLayoutRoute exact path={routes.home} component={HomePage} />
<PageLayoutRoute path={routes.studio} component={StudioPage} />
<PageLayoutRoute path={routes.framing} component={FramingPage} />
{/* */}
<PageLayoutRoute path="/checkout" component={OrderReviewPage} />
<PageLayoutRoute path="/orderConfirmed" component={OrderConfirmationPage} />
</Switch>
</Router>
</Provider>
</SocialIntegrator>;
export default App;
出口/进口
因此,我在每个文件夹中使用带有index.js
的子文件夹来导出每个组件。
导出:Social/index.js
export { default as SocialIntegrator } from "./controls/SocialIntegrator";
导入:index.js
import { SocialIntegrator } from "components/Social";
环境
节点-v
:v8.4.0npm-v
:v4.6.1纱线-版本
(如果使用纱线):0.20.0npm ls react脚本
(如果尚未弹出):v1.0.14请参见我的解释:未捕获类型错误:
您正在使用一个依赖于私有API的库。那些API已经不存在了。(而且从未打算直接使用。)您如何呈现应用程序?像这样的?您的目标是有效的DOM元素吗<代码>React.render(,document.getElementById('root')代码>是的<代码>ReactDOM.render(,document.getElementById(“根”)代码>刚刚复制了这个问题。这很相似。对不起,花了不少时间。非常感谢你!对于看到这篇文章的人来说,它是由只支持react 15的“opbeat”应用程序引起的,而我使用的是react 16。
export { default as SocialIntegrator } from "./controls/SocialIntegrator";
import { SocialIntegrator } from "components/Social";