From 643872ecba99c350a4ea583929a93e6388cfab59 Mon Sep 17 00:00:00 2001 From: Gunnar Torfi Date: Sat, 7 Sep 2024 12:18:41 +0000 Subject: [PATCH] feat!: rename onPress to onClick for Action --- example/src/ToastDemo.tsx | 8 ++++---- src/toast.tsx | 4 ++-- src/types.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/src/ToastDemo.tsx b/example/src/ToastDemo.tsx index ce6edb4..23ff126 100644 --- a/example/src/ToastDemo.tsx +++ b/example/src/ToastDemo.tsx @@ -48,7 +48,7 @@ export const ToastDemo: React.FC = () => { toast.success('Changes saved', { action: { label: 'See changes', - onPress: () => { + onClick: () => { console.log('Action pressed'); }, }, @@ -81,7 +81,7 @@ export const ToastDemo: React.FC = () => { const id = toast('Blue screen of death', { action: { label: 'OK', - onPress: () => { + onClick: () => { toast.dismiss(id); }, }, @@ -227,7 +227,7 @@ export const ToastDemo: React.FC = () => { dismissible: false, action: { label: 'Acknowledge', - onPress: () => { + onClick: () => { toast.dismiss(id); setToastId(null); }, @@ -249,7 +249,7 @@ export const ToastDemo: React.FC = () => { toast('My cancel toast', { cancel: { label: 'Cancel', - onPress: () => console.log('Cancel!'), + onClick: () => console.log('Cancel!'), }, }); }} diff --git a/src/toast.tsx b/src/toast.tsx index b1c8f16..8abe386 100644 --- a/src/toast.tsx +++ b/src/toast.tsx @@ -242,7 +242,7 @@ export const Toast: React.FC = ({ > {action ? ( = ({ {cancel ? ( { - cancel.onPress(); + cancel.onClick(); onDismiss?.(id); }} className={cancelButtonClassName} diff --git a/src/types.ts b/src/types.ts index 7621436..93b8f10 100644 --- a/src/types.ts +++ b/src/types.ts @@ -43,7 +43,7 @@ export type ToastVariant = 'success' | 'error' | 'info'; export type ToastAction = { label: string; - onPress: () => void; + onClick: () => void; }; export type ToastProps = StyleProps & {