-
Notifications
You must be signed in to change notification settings - Fork 90
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
Remove useless line (i think) #53
Conversation
``` var newComponentProps = Object.assign({}, props, { style: style, className: className, disabled: props.disabled, handlers: this.handlers }, this.handlers()); ``` I'm not sure but it seems to me this line `handlers: this.handlers` is useless right?
@nmn this is your code, can you advise? |
@JedWatson Hold on... That line is useless, as props is already mixed, so disabled is being set twice.
handlers: function () {
return {
onTouchStart: this.onTouchStart,
onTouchMove: this.onTouchMove,
onTouchEnd: this.onTouchEnd,
onMouseDown: this.onMouseDown,
onMouseUp: this.onMouseUp,
onMouseMove: this.onMouseMove,
onMouseOut: this.onMouseOut
};
} So when mixing the result of handlers is being set to the function itself, not the result. This is for backwards compatibility for people who rely on |
oh ok I did not know about this backward compatibility issue as I did not know we were able to use this.props.handlers |
@slorber react-tappable is very versatile right now. It can be used a component, a HOC and a mixin. If you use it as a HOC you can set up the event Handlers like so:
And
If you use it as a mixin you would set up like so:
Hope that clears it up a bit. |
@nmn yes i've seen that However I'm not sure Tappable is a HOC can you explain a little bit more please? |
@nmn could you please clearify what you mean by
|
(@slorber Sorry I didn't reply sooner. Missed it in my github notifications somehow) I'll try my best to document how react-tappable can be a HOC. Normal Component
In this case, a Mixin
Here you can extend your own custom component with the tap handler. Using the mixin, you get all the required click and touch handlers by calling HOC
Here, even if you use ES6 classes, you can extend them with But if you want to use a custom component, you will need to bind the click and touch handlers yourself. Just like when you used a mixin. Now, to make this process easier, the Let me know if there's still confusion regarding this. |
hmmm for me your HOC is not a HOC, it's just a runtime wrapper that can be parametrized with a custom component |
@slorber I accept that! |
I'm not sure but it seems to me this line
handlers: this.handlers
is useless right?