0

So I'm building a react-JS website with express serving the back-end. I'm using react-router and react-stormpath for authentication. Using webpack as well. I'm having issues with bootstrap javascript loading. I installed react-bootstrap and am serving the css file from express with no problem. However, when I try to render, I get several errors, one pertaining to ReactDOM not recognizing ReactDOM(Uncaught ReferenceError: ReactDOM is not defined(…)), and another 2 pertaining to bootstrap(Uncaught TypeError: Cannot read property 'PropTypes' of undefined(…) & Uncaught SyntaxError: Unexpected token :). This is my first React application, so any help would be greatly appreciated!

/* 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')
);
duncanhall
  • 11,035
  • 5
  • 54
  • 86
Eric Han
  • 45
  • 2
  • 10
  • Please share each error stack traces. Did you verify there was not two versions of React loaded? – Damien Leroux Nov 02 '16 at 08:56
  • Why are you rendering things into the `app` element twice? – arthurakay Nov 02 '16 at 10:28
  • With regards to why I render to the app element twice, I'm not to sure how react-router works. Does rendering the routes automatically display a view if I have the component classes done? Also, here are my stack traces: – Eric Han Nov 09 '16 at 05:35
  • react-bootstrap.js:2037 Uncaught TypeError: Cannot read property 'PropTypes' of undefined(…)exports.__esModule @ react-bootstrap.js:2037__webpack_require__ @ react-bootstrap.js:30exports.__esModule @ react-bootstrap.js:430__webpack_require__ @ react-bootstrap.js:30exports.__esModule @ react-bootstrap.js:62__webpack_require__ @ react-bootstrap.js:30exports.__esModule @ react-bootstrap.js:50(anonymous function) @ react-bootstrap.js:53webpackUniversalModuleDefinition @ – Eric Han Nov 09 '16 at 05:37
  • react-bootstrap.js:9(anonymous function) @ react-bootstrap.js:10 PanelGroup.js:10Uncaught TypeError: Cannot read property 'PropTypes' of undefined(…)e.__esModule.default @ PanelGroup.js:10t @ bootstrap 1f3bd0d…:19t.exports @ react-bootstrap.min.js:62t @ bootstrap 1f3bd0d…:19t @ bootstrap 1f3bd0d…:39(anonymous function) @ bootstrap 1f3bd0d…:39(anonymous function) @ universalModuleDefinition:9(anonymous function) @ react-bootstrap.min.js.map:1 Uncaught SyntaxError: Unexpected token : transformed.js:41175 Uncaught ReferenceError: ReactDOM is not defined(…) – Eric Han Nov 09 '16 at 05:38
  • I ssolved the bootstrap problems. but it still says ReactDOM is not defined. I'm sure I imported it correctly. Any clues or hints? – Eric Han Nov 15 '16 at 09:11

2 Answers2

1

Try to import prototypes as follows: import PropTypes from 'prop-types'

Orlandster
  • 4,706
  • 2
  • 30
  • 45
Djesu
  • 117
  • 1
  • 6
0

Before import proptypes you have to first install proptypes as follows:

npm install proptypes

Djesu
  • 117
  • 1
  • 6