Skip to content

Commit

Permalink
Merge pull request #24 from gunnartorfis/onclick
Browse files Browse the repository at this point in the history
feat!: rename onPress to onClick for Action
  • Loading branch information
gunnartorfis authored Sep 7, 2024
2 parents 0d93453 + 643872e commit c0ba9bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions example/src/ToastDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ToastDemo: React.FC = () => {
toast.success('Changes saved', {
action: {
label: 'See changes',
onPress: () => {
onClick: () => {
console.log('Action pressed');
},
},
Expand Down Expand Up @@ -81,7 +81,7 @@ export const ToastDemo: React.FC = () => {
const id = toast('Blue screen of death', {
action: {
label: 'OK',
onPress: () => {
onClick: () => {
toast.dismiss(id);
},
},
Expand Down Expand Up @@ -227,7 +227,7 @@ export const ToastDemo: React.FC = () => {
dismissible: false,
action: {
label: 'Acknowledge',
onPress: () => {
onClick: () => {
toast.dismiss(id);
setToastId(null);
},
Expand All @@ -249,7 +249,7 @@ export const ToastDemo: React.FC = () => {
toast('My cancel toast', {
cancel: {
label: 'Cancel',
onPress: () => console.log('Cancel!'),
onClick: () => console.log('Cancel!'),
},
});
}}
Expand Down
4 changes: 2 additions & 2 deletions src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const Toast: React.FC<ToastProps> = ({
>
{action ? (
<Pressable
onPress={action.onPress}
onPress={action.onClick}
className={actionButtonClassName}
style={[
unstyled
Expand Down Expand Up @@ -284,7 +284,7 @@ export const Toast: React.FC<ToastProps> = ({
{cancel ? (
<Pressable
onPress={() => {
cancel.onPress();
cancel.onClick();
onDismiss?.(id);
}}
className={cancelButtonClassName}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ToastVariant = 'success' | 'error' | 'info';

export type ToastAction = {
label: string;
onPress: () => void;
onClick: () => void;
};

export type ToastProps = StyleProps & {
Expand Down

0 comments on commit c0ba9bf

Please sign in to comment.