Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

ignore invalid arguments to increment/decrement/etc. #2

Open
ianstormtaylor opened this issue Jul 10, 2018 · 2 comments
Open

ignore invalid arguments to increment/decrement/etc. #2

ianstormtaylor opened this issue Jul 10, 2018 · 2 comments

Comments

@ianstormtaylor
Copy link
Owner

ianstormtaylor commented Jul 10, 2018

Right now, the convenience transforms are "smart" in that if you do:

<NumberValue>
  {({ increment }) => (
    <button onClick={increment} />
  )}
</NumberValue>

It will fail because it's actually being called as increment(event). Instead you have to write it as:

<NumberValue>
  {({ increment }) => (
    <button onClick={() => increment()} />
  )}
</NumberValue>

But this is such a common use case that it might be nice to either ignore Event objects specifically, or just ignore anything that isn't a "valid" value.

It's also easy to forget this, because onClick={toggle} or onClick={clear} works since they don't care about the event argument in the first place.

@lxe
Copy link

lxe commented Jul 11, 2018

We should not ignore the explicit conventions and signature of onClick.

Also... I think this is a good case for TypeScript / Flow definitions!

@ianstormtaylor
Copy link
Owner Author

@lxe can you explain? I'm not sure I understand what you mean. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants