0

因此,我正在构建一个 react-JS 网站,并使用 express 服务于后端。我正在使用 react-router 和 react-stormpath 进行身份验证。也使用 webpack。我在加载引导 javascript 时遇到问题。我安装了 react-bootstrap 并从 express 提供 css 文件,没有问题。但是,当我尝试渲染时,我收到了几个错误,一个与 ReactDOM not Recogniz 相关 ReactDOM(Uncaught ReferenceError: ReactDOM is not defined(…)),另一个与bootstrap(Uncaught TypeError: Cannot read property 'PropTypes' of undefined(…) & Uncaught SyntaxError: Unexpected token :). 这是我的第一个 React 应用程序,任何帮助将不胜感激!

/* jshint esversion: 6 */
import React, { PropTypes } from 'react'
import ReactDOM from 'react-dom'
import { LoginLink } from 'react-stormpath'

import ReactStormpath, { Router, HomeRoute, LoginRoute, AuthenticatedRoute } from 'react-stormpath'
import { Link, IndexRoute, Route, browserHistory } from 'react-router'
import { MasterPage, IndexPage, LoginPage, RegistrationPage, ProfilePage } from './pages'

import Index from './components/Index'
import index from './pages/index'

console.log("app.js loaded");

ReactStormpath.init();
ReactDOM.render(
  <Router history={browserHistory}>
    <HomeRoute path='/' component={MasterPage}>
      <IndexRoute component={IndexPage} />
      <LoginRoute path='/login' component={LoginPage} />
      <Route path='/register' component={RegistrationPage} />
      <AuthenticatedRoute>
        <HomeRoute path='/profile' component={ProfilePage} />
        <Route path='/:user/lists' component={List} />
      </AuthenticatedRoute>
      <Route path='/lists' component={List} >
        <Route path="/lists/:list" component={List} />
      </Route>
    </HomeRoute>
  </Router>,
  document.getElementById('app')
);

ReactDOM.render(
  <ListForm />,
  document.getElementById('app')
);
4

2 回答 2

1

尝试按如下方式导入原型:import PropTypes from 'prop-types'

于 2018-03-10T23:22:25.817 回答
0

在导入 proptypes 之前,您必须先安装 proptypes,如下所示:

npm 安装属性类型

于 2018-03-10T23:28:54.157 回答