@nas-user/tango-router
v1.4.0
Published
Dead simple router for @nas-user/tango
Downloads
6
Readme
@nas-user/tango-router
Dead simple router for @nas-user/tango
Wraps react-router + react-router-redux and provides the simplest API possible. Built for @nas-user/tango, but will work in any redux application.
Install
npm install --save @nas-user/tango-router
Repository
https://github.com/rtobon/tango-router.git
Get Started
- Import in the module
- Add it to your store's plugins
- Router state is now under
router
in your store
Example
import { createStore } from '@nas-user/tango'
import * as router from '@nas-user/tango-router'
// you get the point
let store = createStore({
plugins: [ router ]
})
API
- history
- actions
- reducers
- middleware
- hook
Components
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
Auth
handling authentication
Props
store
- Redux storeoptions
- Options Object
Options Object Keys
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