您好我正在尝试执行此教程,但是在我添加react-router
后我发现错误,代码在向其添加react-router
之前就已经运行了:
未捕获的SyntaxError:
- 意外的令牌<
- 和未捕获错误:元素类型无效:预期字符串(用于内置组件)或类/函数(用于复合组件)
但得到了:未定义。
任何线索?谢谢你的帮助。
import React, { Component } from 'react';
import ReactDOM from "react-dom";
import css from './css/style.css';
import { Router, Route, Navigation } from 'react-router';
class App extends Component {
render() {
return(
<div className="catch-of-the-day">
<div className="menu">
<Header tagline="Fresh Seafood Market" />
</div>
<Order />
<Inventory />
</div>
)
}
}
//header
class Header extends Component {
render() {
return (
<header className="top">
<h1>Catch
<span className="ofThe">
<span className="of">of</span>
<span className="the">the</span>
</span>
Day</h1>
<h3 className="tagline"> <span>{this.props.tagline}</span></h3>
</header>
)
}
}
class Order extends Component {
render() {
return (
<p>Order</p>
)
}
}
class Inventory extends Component {
render() {
return (
<p>Inventory</p>
)
}
}
class StorePicker extends Component {
render(){
return (
<form className="store-selector">
<h2>Please Enter A store</h2>
<input type="text" ref="storeId" required />
<input type="submit" />
</form>
)
}
}
//Routes
const routes = (
<Router>
<Route path="/" component={StorePicker}/>
<Route path="/store/:storeId" component={App}/>
</Router>
)
ReactDOM.render(routes, document.getElementById('main'));