React Observatory
  • Introduction
  • Motivation
  • Dynamic Injection
    • Reducers
    • Epics
  • API Reference
    • applyAsyncEpics
    • applyAsyncReducers
    • composeReducerCreator
    • createRootEpic
    • injectEpic
    • injectReducer
    • withAction
    • withRouterAction
Powered by GitBook
On this page
  • Arguments
  • Returns
  • Example: Dispatching an Action, when the Container is mounted.
  • ./src/containers/About
  1. API Reference

withRouterAction

PreviouswithAction

Last updated 6 years ago

for dispatching an action with the data from the router context, when the route is matched and corresponding component is about to mount.

The action will receive the and the from

withRouterAction(action) is useful, when you want to run side-effects in the Epics right after Component being loaded.

Arguments

  1. action (string): Redux to dispatch.

Returns

(Function): A function that enables us to dispatch an when Component is mounted.

Example: Dispatching an when the Container is mounted.

./src/containers/About

import { withRouterAction } from '@react-observatory/with-router-action'
import About from './About'

// It's nice to prefix the Actions, so it's easy to recognize them in the DevTool.
export default withRouterAction('RouterAction.About')(About)
Higher-Order Components
location
match
react-router.
Action
Higher-Order Components
Action,
Action,