Created
July 6, 2015 16:03
-
-
Save guillaume86/e09d0b58e4381e02b638 to your computer and use it in GitHub Desktop.
redux-react-router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { createRedux } from 'redux'; | |
import { provide } from 'redux/react'; | |
import { Router } from 'react-router'; | |
import { history } from 'react-router/lib/HashHistory'; | |
import routes from './routes'; | |
const redux = createRedux({}); | |
@provide(redux) | |
class App { | |
render() { | |
return ( | |
<Router history={history} children={routes}/> | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export class Layout { | |
render() { | |
return ( | |
<div className='layout'> | |
<h1>My app</h1> | |
<div class='content'> | |
{ this.props.children } | |
</div> | |
</div> | |
); | |
} | |
} | |
export class Home { | |
render() { | |
return (<h2>Home</h2>); | |
} | |
} | |
export class About { | |
render() { | |
return (<h2>About</h2>); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Layout, Home, About } from './components'; | |
// component syntax equivalent: <Route ... /> | |
export default const routes = { | |
component: Layout, | |
childRoutes: [ | |
{ path: '/', component: Home }, | |
{ path: '/about', component: About } | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment