javascript - TypeError: Object (...) is not a function in react & js
问题描述
我有这段代码,但由于某种原因,它因错误而失败:
TypeError: Object(…) is not a function
它说它发生在第 70 行,就是这样:
export default withAuthentication(App)
这是我的这个页面的代码,它导入包,代码,然后在最后导出:
import React from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
//import 'antd/dist/antd.css'
// (loading styles with with react-app-rewired / fixBabelImports / addLessLoader) to get overrides on colors and fonts
import * as routes from './routes'
import withAuthentication from './withAuthentication'
import AuthUserContext from './AuthUserContext'
import SignUpPage from './pages/SignUpPage'
import LoginPage from './pages/LoginPage'
import PasswordForgetPage from './pages/PasswordForgetPage'
import MainPage from './pages/MainPage'
import NewClientPage from './pages/NewClientPage'
import EditClientPage from './pages/EditClientPage'
import NewEstimatePage from './pages/NewEstimatePage'
import EditEstimatePage from './pages/EditEstimatePage'
import TestPage from './pages/TestPage'
import UserProfileContent from './components/UserProfileContent'
import StripeApp from './Stripepayment/StripeApp'
import NameRegistration from './components/NameField'
// import App from './App.js'
const App = ({ authUser }) => {
return <AuthUserContext.Consumer>
{ authUser => authUser
? <LoggedInApp authUser={authUser}/>
: <NotLoggedInApp />
}
</AuthUserContext.Consumer>
}
const NotLoggedInApp = () =>
<Switch>
<Route exact path={routes.SIGN_IN} component={LoginPage} />
<Route exact path={routes.SIGN_UP} component={SignUpPage} />
<Route exact path={routes.PASSWORD_FORGET} component={PasswordForgetPage} />
<Route exact path={routes.NAMEREGISTER} component={NameRegistration} />
<Route exact path={routes.STRIPEAPP} component={StripeApp} />
<LoginPage />
</Switch>
const TabRoute = ({ path }) =>
<Route exact path={path} render={(props) => <MainPage showTab={path} {...props} />} />
const LoggedInApp = ({ authUser }) =>
<Switch>
<Route exact path={routes.SIGN_IN} component={LoginPage} />
<Route exact path={routes.NEWCLIENT} component={NewClientPage} />
<Route exact path={routes.EDITCLIENT + '/:id'} render={(props) => <EditClientPage clientId={props.match.params.id} />}/>
<Route exact path={routes.NEWESTIMATE} component={NewEstimatePage} />
<Route exact path={routes.EDITESTIMATE + '/:id'} render={(props) => <EditEstimatePage estimateId={props.match.params.id} />}/>
<Route exact path={routes.TEST} component={TestPage} />
<Route exact path={routes.PASSWORD_FORGET} component={PasswordForgetPage} />
<Route exact path={routes.CLIENTS + '/:id'} render={(props) => <MainPage showTab={routes.CLIENTS} {...props} />} />
<Route exact path={routes.ESTIMATES + '/:id'} render={(props) => <MainPage showTab={routes.ESTIMATES} {...props} />} />
<Route exact path={routes.JOBS + '/:id'} render={(props) => <MainPage showTab={routes.JOBS} {...props} />} />
<TabRoute path={routes.CLIENTS} />
<TabRoute path={routes.ESTIMATES} />
<TabRoute path={routes.JOBS} />
<TabRoute exact path={routes.PROFILE} component={UserProfileContent}/>
<Redirect to={routes.CLIENTS} />
</Switch>
export default withAuthentication(App)
解决方案
推荐阅读
- ubuntu - 如何更改用户的默认主目录?- 许本图
- python - 时间序列的区间预测 | 时间序列异常
- r - 如何在 R 中使用 DiagrammR 从 gv 文件中选择节点
- python - 如何在 Python 中为 aws 时间流使用分页?
- reactjs - 为什么路由会重置 redux 状态?
- mysql - 如果 5 年过去了,用于删除数据的 MySQL 事件
- python - subprocess.Popen 在单个测试用例中没有按预期工作
- c# - 如何为 TSP 生成随机坐标?
- node.js - 用node js和socket io创建通知系统的正确方法是什么
- grafana - 如何在 grafana 中为每个分组添加一行而不对多个查询进行硬编码?