Reputation: 2129
I don't understand why the following code produces the error in the title. I checked similar questions, but I did not find them helpful.
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import { createHashHistory } from 'history';
import Menu from './pages/Menu';
import BookShelf from './pages/BookShelf';
import BorrowBook from './pages/BorrowBook';
const App = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
},
render() {
return (
<Menu />
);
}
});
ReactDOM.render((
<Router history={browserHistory} onUpdate={() => window.scrollTo(0, 0)}>
<Route path="/" component={App}/>
<Route path="/menu" component={Menu} />
<Route path="/bookshelf" component={BookShelf} />
<Route path="/borrowbook/:bookId" component={BorrowBook} />
</Router>,
document.getElementById('app')
));
Upvotes: 0
Views: 1386
Reputation: 5590
ReactDOM.render(( // extra parenthesis here
<Router history={browserHistory} onUpdate={() => window.scrollTo(0, 0)}>
<Route path="/" component={App}/>
<Route path="/menu" component={Menu} />
<Route path="/bookshelf" component={BookShelf} />
<Route path="/borrowbook/:bookId" component={BorrowBook} />
</Router>,
document.getElementById('app')
)); // extra parenthesis here
The extra parenthesis are making it so that you are actually passing one argument instead of two.
Upvotes: 2