Comments (4)
Also of use is the pattern laid out in redux-boilerplate by using onEnter
to emit a URL change action. Doesn't cover all use cases but maybe a good majority.
from prism.
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 componentWillReceiveProps
when your router params change (it's pretty common actually in react-router
world).
from prism.
Thanks for replies.
@tomkis1 Your solution works well in my case. Example below (for future reference):
class OrderPage extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.params.id !== nextProps.params.id) {
// this will be dispatched each time the route is changed from `orders/1` to `orders/2`
this.props.dispatch({ type: action.Load, orderId: nextProps.params.id });
}
}
render() { ... }
}
export default view(({ model, dispatch, params }) => (
<OrderPage dispatch={dispatch} model={model} params={params} />
));
@eliperelman onEnter
is nice alternative but I'm afraid that in my case it would be hard to track down all "routing" buttons and add onEnter
to all of them (high probability of runtime bugs).
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.
from prism.
@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.
from prism.
Related Issues (20)
- Don't Call PropTypes HOT 3
- Sibling components interaction best practice HOT 6
- Performance HOT 2
- Request to join cdnjs HOT 1
- Build a umd package for Browser usage
- Reduce bundle size by using rxjs modularity HOT 1
- Mount order and saga registering HOT 8
- Get currentUser state in component Updater HOT 3
- Sagas not getting unmounted HOT 2
- Version 4.x.x HOT 7
- redux-saga update HOT 2
- Documentation links 404 HOT 5
- Where is documentation for v3? HOT 2
- Props 'selector' and 'wrapper' get passed down to enhanced component HOT 3
- prism-redux/escapeRegexp.js is missing a character in the regex
- Questions about using side-effect libraries with prism
- How to wrap/unwrap dynamic components? HOT 2
- Provide a wrapper compatible with the library-provided unwrapper
- EnhanceComponent doesn't work with thunk middleware
- Dynamic list of stateful components HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prism.