From d69f1c1405cf831319b9a1ac98a8ffccefab2329 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 12 Feb 2015 17:02:59 +0300 Subject: [PATCH] Explain getting router state in action creators --- docs/guides/flux.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/guides/flux.md b/docs/guides/flux.md index 29bf63d15c..da49cfa6f4 100644 --- a/docs/guides/flux.md +++ b/docs/guides/flux.md @@ -117,6 +117,21 @@ To avoid this, you can do one of three things: ``` +Accessing route and params from action creators +--------------------------------- + +You can create your own `RouterStore` and fire an action in `run` callback: + +```js +Router.run(routes, (Handler, state) => { + ActionCreators.changeRoute({ state }); + React.render(, document.body); +}); +``` + +Let `RouterStore` keep router state and add a public method to obtain it. +This way your action creators and other stores can learn about current router state. + Handling route changes as actions ---------------------------------