Dead simple router for @eagle/tango
Wraps react-router + react-router-redux and provides the simplest API possible. Built for @eagle/tango, but will work in any redux application.
npm install --save @eagle/tango-router
https://github.com/Graf009/tango-router.git
- Import in the module
- Add it to your store's plugins
- Router state is now under
router
in your store
import { createStore } from '@eagle/tango'
import * as router from '@eagle/tango-router'
// you get the point
let store = createStore({
plugins: [ router ]
})
- history
- actions
- reducers
- middleware
- hook
These are all re-exported from react-router, the behavior is exactly the same. See the react-router documentation if you haven't used these before.
- Router
- Route
- Link
- Redirect
- IndexRoute
- IndexLink
- IndexRedirect
handling authentication
store
- Redux storeoptions
- Options Object
authSelector(state): authData
(Function): A state selector for the auth data.redirectAction
(Function): action for redirecting the user.[failureRedirectPath]
(String): Optional path to redirect the browser to on a failed check. Defaults to/login
[predicate(authData): Bool]
(Function): Optional function to be passed the result of theauthSelector
param. If it evaluates to false the browser will be redirected tofailureRedirectPath
.[allowRedirectBack]
(Bool): Optional bool on whether to pass aredirect
query parameter to thefailureRedirectPath