在CodeSandbox上成功运行时,无法在本地运行react-router示例

时间:2017-12-07 15:22:39

标签: reactjs react-router react-dom

我试图在本地执行react-router's example。但是当我这样做时,我面临以下错误:

Uncaught ReferenceError: React is not defined
    at Object.<anonymous> (index.js:18)
    at t (bootstrap 89d91d26cff14f347b23:19)
    at bootstrap 89d91d26cff14f347b23:62
    at bootstrap 89d91d26cff14f347b23:62

我已设法在CodeSandbox successfully上运行它。所以我将代码简化为:

import React from 'react'
import ReactDOM from 'react-dom'
import {
  BrowserRouter as Router,
  Route,
  Link,
  Redirect,
  withRouter
} from 'react-router-dom'

const AuthExample = () => (
  <h1>Hello World!</h1>
)

ReactDOM.render(<AuthExample />,
  document.getElementById('root')
);

简化版本有效。在我package.json我得到了:

  "dependencies": {
    "bluebird": "3.5.1",
    "express": "4.16.2",
    "object-assign": "4.1.0",
    "react": "16.0.0",
    "react-dom": "16.0.0",
    "react-redux": "5.0.5",
    "react-router-dom": "4.2.2",
    "react-router-redux": "5.0.0-alpha.6",
    "redux": "3.6.0",
    "redux-thunk": "2.1.0",
    "socket.io": "2.0.4"
  },

我知道在没有访问权限的情况下调试代码很困难,但是有什么指针可以告诉我问题可能是什么?

0 个答案:

没有答案