Giter VIP home page Giter VIP logo

Comments (5)

timche avatar timche commented on June 21, 2024

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.

Restuta avatar Restuta commented on June 21, 2024

@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.

timche avatar timche commented on June 21, 2024

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.

Restuta avatar Restuta commented on June 21, 2024

@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.

timche avatar timche commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.