npm.io
1.2.0 • Published 7 years ago

@k-ramel/driver-redux-little-router

Licence
MIT
Version
1.2.0
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
21

@k-ramel/driver-redux-little-router

redux-little-router driver for k-ramel

Examples

In a reaction (See main documentation about listeners/reactions)

Declare it in your store :

import driver from '@k-ramel/driver-redux-little-router'

const router = driver({ routes }, state => state.router, 'router')

createStore(
  {
    // your usual definition
  },
  {
    drivers: { router },
  },
)

In your reaction :

export const onUserLoggedIn = (store, action, drivers) => {
  const { router } = drivers
  // get userId in route params
  const userId = router.getRouteParam('userId')
  // dispatch push action to go to the new route
  router.push(`/user/${userId}`)
}