microcosm-react-router
Sync up react-router with Microcosm. This is experimental, and heavily
inspired by react-router-redux
- Installation
- Setup
- Manipulating History
- Routing Middleware (add query string parsing)
- API
Installation
npm install --save microcosm-react-routernpm install --save historynpm install --save react-router
Setup
microcosm-react-router is implimented through Domains:
{ this } let history = let repo = history // Then pass history to React Router
Manipulating history
Control history by pushing actions:
repo repo
Checkout the history
package for API documentation.
Routing Middleware
Add additional data processing to location data via middleware passed when adding the Location domain:
let repo = let history = let middleware = repo
API
Location Domain
Options
- history: an instance of the history package
- middleware: an array of functions to process raw location data (see middleware)
Middleware
Middleware allow extra processing of location data:
let middleware = // Add parsed query data
Actions
These actions directly map to methods in
the history
package,
which is the underlying kernel for react-router.
push(path, state)
Push a new entry in the history stack.
replace(path, state)
Replace the current entry in the history stack.
go(index)
Visit a specific index in the history stack.
goBack()
Return to the previous history stack entry.
goForward()
Go to the next history stack entry.