Problem
Currently, the onShow callback has the signature () => void, which means it doesn't receive any information about the toast that was just shown.
This makes it difficult to implement common use cases like sending analytics events when a toast is displayed. For example, if you want to track which toast types are being shown to users, you have to maintain external state or use workarounds.
Proposed Solution
Change the onShow signature from:
to:
onShow?: (params: ToastShowParams) => void;
This applies to both ToastOptions and ToastProps.
The onShow() call in useToast.ts would pass through the params that were given to show():
// before
onShow();
// after
onShow(params);
Use Case
<Toast
onShow={(params) => {
analytics.track('toast_shown', {
type: params.type,
text1: params.text1,
});
}}
/>
or per-toast:
Toast.show({
type: 'error',
text1: 'Payment failed',
onShow: (params) => {
analytics.track('toast_shown', { type: params.type });
},
});
Breaking Changes
This is backwards compatible — existing onShow: () => {} callbacks will continue to work since the extra parameter is simply ignored.
Problem
Currently, the
onShowcallback has the signature() => void, which means it doesn't receive any information about the toast that was just shown.This makes it difficult to implement common use cases like sending analytics events when a toast is displayed. For example, if you want to track which toast types are being shown to users, you have to maintain external state or use workarounds.
Proposed Solution
Change the
onShowsignature from:to:
This applies to both
ToastOptionsandToastProps.The
onShow()call inuseToast.tswould pass through theparamsthat were given toshow():Use Case
or per-toast:
Breaking Changes
This is backwards compatible — existing
onShow: () => {}callbacks will continue to work since the extra parameter is simply ignored.