@chanoch/simple-react-router
Advanced tools
Comparing version 0.1.2 to 0.2.1
import ReactDOM from 'react-dom'; | ||
import toRegex from 'path-to-regexp'; | ||
import createHistory from 'history/createBrowserHistory'; | ||
import {createStore, applyMiddleware} from 'redux'; | ||
import StoreCreator from './StoreCreator'; | ||
@@ -35,6 +35,7 @@ /** | ||
*/ | ||
constructor(rootReducer, initialState, enhancers, routes) { | ||
constructor(routes, rootReducer, initialState, enhancers) { | ||
this.history = createHistory(); | ||
this.routes = routes; | ||
this.store = createStore(rootReducer, initialState, applyMiddleware(...enhancers)); | ||
this.store = StoreCreator(rootReducer, initialState, enhancers); | ||
@@ -41,0 +42,0 @@ // bind the object's methods to this |
{ | ||
"name": "@chanoch/simple-react-router", | ||
"version": "0.1.2", | ||
"version": "0.2.1", | ||
"description": "A simple react router", | ||
@@ -31,2 +31,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -10,2 +10,18 @@ # simple-react-router | ||
## Without redux configuration | ||
```javascript | ||
import HomePage from './HomePage'; | ||
const routes = [ | ||
{ path: '/', action: () => <HomePage /> }, | ||
{ path: '/index.html', action: () => <HomePage /> }, | ||
]; | ||
import {SimpleReactRouter} from '@chanoch/simple-react-router'; | ||
const router = new SimpleReactRouter(routes); | ||
``` | ||
## With redux configuration | ||
1. Define the routes | ||
@@ -16,3 +32,3 @@ 2. Define reducers and initial state | ||
5. Instantiate the router | ||
6. Load aync server data | ||
6. Load async server data | ||
@@ -74,1 +90,5 @@ You can optionally dispatch a state on loading of application data from the server | ||
3. Link to webpack tut on setting up a simple project | ||
4. Testing | ||
## Change Log | ||
* 0.1 to 0.2 - implemented smart defaulting to null implementations for state, middleware, and reducer, Moved routes parameter which defines valid navigation to front of list to make those related to redux optional. |
22614
5
175
91