Skip to content

Instantly share code, notes, and snippets.

@guillaume86
Created July 6, 2015 16:03
Show Gist options
  • Save guillaume86/e09d0b58e4381e02b638 to your computer and use it in GitHub Desktop.
Save guillaume86/e09d0b58e4381e02b638 to your computer and use it in GitHub Desktop.
redux-react-router
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}/>
);
}
}
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>);
}
}
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