Support onClick
prop, ref
on BuyNowButton
#708
joshbuckley182
started this conversation in
Ideas + Feature Requests
Replies: 2 comments
-
Hi @joshbuckley182 this issue is tracking: Shopify/hydrogen#717 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Released in v0.25.0 https://github.com/Shopify/hydrogen/releases/tag/%40shopify%2Fhydrogen%400.25.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be good if we can supply our own
onClick
prop to be executed before (potentially async and blocking) the default behavior. Another option would be to be able to create a ref to the button, so we can trigger a click event after performing some other task.Use case:
I need to track
click
events on aBuyNowButton
. What I’m finding though, is the page navigation happens before the event has been sent to the tracking server. This seems like something other users of Hydrogen might also want to do too. (Note: Right now I’m capturing the click in a parent element to trigger the tracking call).I see a few options here:
TrackableBuyNowButton
with a similar implementation to the Hydrogen one. Pro: Easy, Con: Need to ensure we stay in-sync with the Hydrogen oneonBeforeRedirect
(or similar) prop on theBuyNowButton
which would be executed and resolved before performing the redirect.BuyNowButton
so we can trigger a click after the tracking call has completed.Another option would be to track the event using the
beacon
api, but that’s not compatible with all types of tracking.Beta Was this translation helpful? Give feedback.
All reactions