我有這個文件在我的reactapp中導致錯誤。無法獲取未定義或空引用的屬性「位置」ReactJS
import React from 'react';
import { Router, Route } from 'react-router';
import App from './components/App';
import About from './components/About';
import NotFound from './components/NotFound';
const Routes =() => (
<Router>
<Route path="/" component={App} />
<Route path="/about" component={About} />
<Route path="*" component={NotFound} />
</Router>
);
export default Routes;
出於某種原因,如果我更換
<Router>
<Route path="/" component={App} />
<Route path="/about" component={About} />
<Route path="*" component={NotFound} />
</Router>
只是一個簡單的內容,如<div> hi </div>
話,我可以看到我的應用程序嗨,否則我得到這個錯誤。
TypeError: Unable to get property 'location' of undefined or null reference