最佳答案
I'm trying to set up react-router in an example application, and I'm getting the following error:
You should not use <Link> outside a <Router>
My app is set up like so:
const router = (
<div className="sans-serif">
<Router histpry={browserHistory}>
<Route path="/" component={Main}>
<IndexRoute component={PhotoGrid}></IndexRoute>
<Route path="/view/:postId" component={Single}></Route>
</Route>
</Router>
</div>
);
render(<Main />, document.getElementById('root'));
Main
componentexport default () => (
<div>
<h1>
<Link to="/">Redux example</Link>
</h1>
</div>
)
Any idea what I'm doing wrong here?
Here's a Sandbox link to demonstrate the problem.