Skip to content

Instantly share code, notes, and snippets.

@syang
Created April 6, 2017 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syang/206e539c8892de43c051444bf070385e to your computer and use it in GitHub Desktop.
Save syang/206e539c8892de43c051444bf070385e to your computer and use it in GitHub Desktop.
a not working react-router (have not figured out why)
// index.js (where everything gets started)
// ...
render(
(
<BrowserRouter>
<Route path="/" component={App}>
<IndexRoute component={Feeds} />
<Route path="/repos" component={Repos}/>
<Route path="/about" component={About}/>
</Route>
</BrowserRouter>
),
document.getElementById('root')
);
--------------------
// App.js
import React, { Component } from 'react';
import Navbar from './navbar'
class App extends Component {
render () {
return (
<div >
<div className='navbar-container'>
<Navbar />
</div>
<div>
{this.props.children}
</div>
</div>
);
}
}
export default App;
---------------------
// navbar.js
// ...
import React, { Component } from 'react';
import Navbar from './navbar'
class App extends Component {
render () {
return (
<div >
<div className='navbar-container'>
<Navbar />
</div>
<div>
{this.props.children}
</div>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment