react-root
v2.0.1
Published
Root component for bootstrapping react, react-router, redux
Downloads
14
Readme
React <Root />
Because I don't want to deal with boilerplates and starters.
Install
$ npm install --save react-root
Usage
import React from 'react'
import { render } from 'react-dom'
import { Root, createStore } from 'react-root'
const middleware = [
// any redux middleware you need
]
const reducers = {
// object of your reducers
}
const store = createStore(middleware, reducers)
const routes = <Route path='/' component={App}>
<Route path='home' component={Home} />
</Route>
render(
<Root routes={routes} store={store} />,
document.getElementById('app')
)
See the example to see how easy it is to get started!
Redux Devtools
Install the Redux Devtools browser extension.
Hot reloading your reducers
If you need to hot reload reducers in development, you can pass a function as the 4th parameter to creatStore
in order to get the store instance so you can call replaceReducer
. This function is only ever called if module.hot === true
:
const store = createStore(middleware, reducers, storeEnhancers, store => {
module.hot.accept('./reducers', () => {
store.replaceReducer(require('./reducers').default)
})
})
What's inside?
- redux
- react-redux
- react-router
- react-router-redux
Related Projects
- superdevpack Use react-root and superdevpack together for the quickest way to get started on a React project.