Comments (5)
onChange
passes an event
as parameter to the action creator as payload, that's correct.
What you can do instead is writing something like this:
<input type="checkbox" onChange={() => props.toggleBaseline()}>
or
export default connect(state => state.debug, dispatch => ({
toggleBaseline: () => dispatch(toggleBaseline())
}))(DebugGrid)
from redux-actions.
@timche Yes, but that is not the point, point is that you can easily run into confusing issues (at least I was able to) with this approach. In general this sounds like a trick default behaviour. Did you see a problem at that time when I asked about it in my post?
Also use of arrow functions in there is discouraged https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
I workarounded this with:
const makeActionCreator = (type, payloadCreator, metaCreator) =>
createActionCreator(type, payloadCreator || (() => {}), metaCreator)
But that is just workaround.
from redux-actions.
I know that, it was only an example to keep it short ;)
I don't really get your point then, sorry :/ The identity function takes an parameter as payload as it is stated in the docs. What's confusing about this?
from redux-actions.
@timche I am sorry for not being clear. I tried my best in explanation above and that if you follow normal path with that behaviour it's easy to get into a trap.
"Normal path" is the following:
Define action creators => pass action creators to connect
=> call them directly from JSX event handlers => trap
This path looks normal to me, it's recommended path in Redux docs and it leads to a problem, which, presumably a lot of people would not even realize (unless they use Redux Dev Tools).
I understand that it maybe only me and the rest is doing it just fine and understand everything and stuff =), that's why I tried to ask if you saw a problem back then while reading my comment. If you did not then you part of the community who fell into a trap.
If subjectively this is valid problem, then it requires some attention. I don't want to jump into solutions right away, before we align that it is a potential issue for newcomers.
Does this make sense?
from redux-actions.
Tbh, I don't see an issue with this, because event handlers are working like expected for me personally (or see here). If anyone should see a problem here as well, then I'm willing to reopen this issue again, otherwise I'll close it for now.
from redux-actions.
Related Issues (20)
- [Feature request] Function value for defaultState HOT 1
- it's support immutable.js?
- can't use Map on handleActions HOT 2
- combine-actions prefixing bug
- Error handling on action payload HOT 2
- Docs: broken link
- Suddenly can't add an action... HOT 3
- How to use react hooks aftrer reducer change for the lib?
- Does state changing is async? HOT 3
- Looking for Maintainers
- React SSR handleActions cache bug HOT 1
- handleActions with Immer. HOT 1
- Wierd behavior with just not recognizing string templated reducer HOT 1
- 'to-camel-case' pacakge introducing bug since it's not compatible with 'lodash.camelCase' HOT 1
- v3.0.0 + TypeScript Cannot find module 'redux-actions' from ... HOT 12
- Import fails to identify entry point HOT 2
- can redux-actions be used with redux-thunk?
- Not Working with React Native from v.3.0.0
- Compilation error in `react-native:0.71.8` HOT 1
- Not working with `Jest` from v3.0.0 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 redux-actions.