我正在使用带有 create-react-app 的 React Router v4.0.0-alpha.3,如下所示:
// For react app
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Match, Miss } from 'react-router';
import './css/style.css';
// For electron app ~
import './ReactotronConfig'
import StorePicker from './components/StorePicker'
import App from './components/App'
class NotFound extends React.Component {
render() {
return (
<div>Not Found.</div>
)
}
}
const Root = () => {
return (
<BrowserRouter>
<div>
<Match exactly pattern="/" component={StorePicker} />
<Match pattern="/store/:storeId" component={App} />
<Miss component={NotFound} />
</div>
</BrowserRouter>
);
}
render(
<Root />,
document.querySelector('#main')
)
我收到这些错误。
我发现在网上造成这种情况的唯一原因是我可能导入不正确,但我是 AFAIK。我很确定我忽略了一些非常明显的东西。
App 和 Storepicker 的代码:
import React from 'react'
import Header from './Header'
import Order from './Order'
import Inventory from './Inventory'
const App = ({...props}) => (
<div className='catch-of-the-day'>
<div className='menu'>
<Header tagline="Fresh Seafood Market" />
</div>
<Order />
<Inventory />
</div>
)
export default App
--
import React, {Component} from 'react'
class StorePicker extends Component {
render() {
return (
<form className='store-selector'>
<h2>Please Enter A Store</h2>
<input type='text' required placeholder='Store Name'/>
<button type='submit'>Visit Store ☞</button>
</form>
)
}
}
export default StorePicker