withRouterAction

Higher-Order Componentsarrow-up-right 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 locationarrow-up-right and the matcharrow-up-right from react-router.arrow-up-right

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

Arguments

  1. action (string): Redux Actionarrow-up-right to dispatch.

Returns

(Function): A Higher-Order Componentsarrow-up-right function that enables us to dispatch an Action,arrow-up-right when Component is mounted.

Example: Dispatching an Action,arrow-up-right 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)

Last updated