Laco Inferno Router
laco-inferno-router
is a replacement for Redux First Router which makes routing a part of the state.
Routing now works with time travel and you can dispatch routing related actions that get logged in the debugger.
Example
const Counter = <Subscribe to=RouterStore> <Switch location=statepathname> <Route exact path="/" component=Home /> <Route exact path="/test" component=Test /> <Route component=NoMatch /> </Switch> </Subscribe>
Check out the examples
folder.
API
Refer to React Router documentation for following components:
- Route
- Switch
- Link
RouterStore
This is the main store for routing.
// Getting the state of the storeRouterStore// Outputs something like:// {// hash: "",// pathname: "/",// search: ""// }
Actions
You may want to have more control of the routing history. You can do that by dispatching following actions:
- push(path: string)
- replace(path: string)
- go(n: number)
- goBack()
- goForward()
Actions gets automatically logged in the debugger.
For more information check out the history API here.
Credits
Heavily inspired by: