Open jaredpalmer opened 7 years ago
@jaredpalmer what kind of API do you have in mind? I've been discussing with workmates the following:
<Tracking
action="click"
label={event => event.currentTarget.textContent}
onClick={() => console.log('Some custom optional callback')}
>
{trackingProps => (
<Button btnStyle="facebook" {...trackingProps}>
Like us on Facebook!
</Button>
)}
</Tracking>
The trackingProps object would have the onClick callback, in this case, but it could be anything: onExpand, onClose, etc. Does it make sense?
What about tracking on mount?
The Tracking component takes care of it. It could also inject listeners into the document (scroll, online, deviceorientation), for ex.
This gets hard to type with flow/ts if you couple the naming of the handler to the event
It doesn't necessarily need to be named onClick. It could be callback, for ex.
Hey @jaredpalmer would be happy to accept a PR to support the render prop pattern, however the existing HoC pattern would still need to be supported.