Skip to content

Instantly share code, notes, and snippets.

@mohandere
Last active February 16, 2018 13:01
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 mohandere/3fffd5a4fe491e56c1ca64acce4677b1 to your computer and use it in GitHub Desktop.
Save mohandere/3fffd5a4fe491e56c1ca64acce4677b1 to your computer and use it in GitHub Desktop.
routes.js + index.js
// File - src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import registerServiceWorker from './registerServiceWorker';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
// Import store and history
import store, { history } from './store';
// common components
import Header from './common/containers/Header'
import Menus from './common/containers/Menus'
import Footer from './common/containers/Footer'
// routes
import routes from './routes';
// Render App
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div className="App">
<Header />
<Menus />
<div className="wrap">
{routes}
</div>
<Footer />
</div>
</ConnectedRouter>
</Provider>,
document.getElementById('root')
);
registerServiceWorker();
// File - src/routes.js
import React from 'react';
import { Route, Switch } from 'react-router';
// Module root components
import Home from './home';
import Catalog from './catalog';
import Product from './product';
import Archives from './archives';
import PageNotFound from './common/components/PageNotFound';
export default (
<Switch>
<Route exact path="/catalog" component={Catalog}/>
<Route exact path="/product/:productId" component={Product}></Route>
<Route exact path="/designers" component={Designers}/>
<Route exact path="/articles" component={Archives}/>
<Route exact path="/articles/category/:slug" component={Archives}/>
<Route exact path="/" component={Home}/>
<Route path="*" component={PageNotFound} />
</Switch>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment