reactatouille
Version:
Reactatouille is a command-line tool to help quickly start and build a new React project, using Redux, Webpack, Gulp (You can add your own tasks, yo!), HMR/Hot Module Reload, Sass (architecture best practices), Jest, Enzyme, popmotion, Redux devtools (bro
25 lines (21 loc) • 673 B
JavaScript
import React from 'react'
import { Route, Switch } from 'react-router'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import rootRoutes from './routes'
const setRoute = (route) => {
const MyComponent = route.component
return <Route key={route.path} path={route.path} render={routeProps => <MyComponent {...Object.assign({}, routeProps, { routes: rootRoutes[0].routes })} />} />
}
const Root = ({store}) => {
return (
<Provider store={store}>
<BrowserRouter>
<Switch>
{ rootRoutes.map(route => setRoute(route)) }
</Switch>
</BrowserRouter>
</Provider>
)
}
export default Root