-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-router @@router/LOCATION_CHANGE available in subcomponents Updaters #40
Comments
Interesting, I was also thinking about such a feature earlier. @slorber was also thinking about something similar (slorber/scalable-frontend-with-elm-or-redux#2). Anyway for your specific usecase, it does make sense to dispatch an action in |
Also of use is the pattern laid out in redux-boilerplate by using |
Thanks for replies.
@eliperelman Anyway @tomkis1 how do you feel about idea of "global" action prefixes. I know that they should not exists in perfectly fractal (Elm) world but for ensuring compatibility with standard react/redux libraries they might be useful. |
@jmarceli I think it's something we can totally consider adding as part of the framework. However, need to figure out proper API. So far having an option to configure "global actions" seems the most sane to me. |
Use componentWillReceiveProps method
see: example below
--- ORIGINAL QUESTION
One of the issues during react-router integration is detecting route changes which doesn't trigger component unmounting. Example:
I've got routes:
orders/1
,orders/2
, etc. (defined withorders/:id
in router)All of them uses same OrderForm subcomponent so if I switch between them the only action triggered is
@@router/LOCATION_CHANGE
(triggered byreact-router
). UnfortunatelyOrderForm
component is nested insideOrderPage
component so it doesn't receive that action (because it is not prefixed properly).My current solution for that is to propagate
@@router/LOCATION_CHANGE
action through all of the updaters with code like the following:Good part is that it works and I can handle
@@router/LOCATION_CHANGE
in subcomponents but I doesn't look nice and requires such code for every level of nesting.Does anyone has any better solution?
Setting
@@
as global prefix would be nice, so all actions prefixed with@@
will be available for all elm components.Even better option would be possibility to define (maybe in array) all "global" action prefixes. It will solve future possible problems with other react libraries (e.g.
redux-form
prefix forredux-form
related actions).The text was updated successfully, but these errors were encountered: