diff --git a/example/src/ToastDemo.tsx b/example/src/ToastDemo.tsx index a4406c9..9d8bdda 100644 --- a/example/src/ToastDemo.tsx +++ b/example/src/ToastDemo.tsx @@ -281,35 +281,19 @@ export const ToastDemo: React.FC = () => { title="Custom JSX" onPress={() => { toast.custom( - - - Custom JSX - - + { fontWeight: '600', }} > - Press me + Custom JSX - + { + console.log('pressed the modal'); + }} + > + + Press me + + + , { duration: 30000, diff --git a/src/toast.tsx b/src/toast.tsx index cd4b3d7..f5ef2e9 100644 --- a/src/toast.tsx +++ b/src/toast.tsx @@ -310,19 +310,15 @@ export const Toast = React.forwardRef( styles?.closeButtonIcon, ]); - if (jsx) { - return jsx; - } - - return ( - { + const toastSwipeHandlerProps = React.useMemo( + () => ({ + onRemove: () => { onDismiss?.(id); - }} - onBegin={() => { + }, + onBegin: () => { isDragging.current = true; - }} - onFinalize={() => { + }, + onFinalize: () => { isDragging.current = false; const timeElapsed = Date.now() - timerStart.current!; @@ -333,18 +329,48 @@ export const Toast = React.forwardRef( } else { onDismiss?.(id); } - }} - onPress={() => onPress?.()} - enabled={!promiseOptions && dismissible} - style={[toastContainerStyleCtx, styles?.toastContainer]} - className={cn( + }, + onPress: () => onPress?.(), + enabled: !promiseOptions && dismissible, + style: [toastContainerStyleCtx, styles?.toastContainer], + className: cn( classNamesCtx?.toastContainer, classNames?.toastContainer - )} - unstyled={unstyled} - important={important} - position={position} - > + ), + unstyled: unstyled, + important: important, + position: position, + }), + [ + onDismiss, + id, + duration, + dismissible, + promiseOptions, + onPress, + toastContainerStyleCtx, + styles?.toastContainer, + classNamesCtx?.toastContainer, + classNames?.toastContainer, + unstyled, + important, + position, + cn, + ] + ); + + if (jsx) { + return ( + + + {jsx} + + + ); + } + + return ( +