diff --git a/package.json b/package.json index f0d1291..0886a4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@platformbuilders/react-native-toast", - "version": "1.4.1", + "version": "1.4.2", "description": "", "author": "Platform Builders ", "repository": { @@ -55,4 +55,4 @@ "styled-components": "^5.3.11", "typescript": "^5.1.3" } -} \ No newline at end of file +} diff --git a/src/Toast.tsx b/src/Toast.tsx index 1e478dc..6dad16d 100644 --- a/src/Toast.tsx +++ b/src/Toast.tsx @@ -165,6 +165,8 @@ export const Toast: FC = ({ data, config }) => { type: 'success', }); + const isValidToast = !!toast.message?.trim() || toast.title?.trim(); + const showCloseButton = config.showCloseButton[data.type]; const disabledAutoHide = config.autoHide[data.type]; const disabledGesture = !disabledAutoHide; @@ -276,11 +278,11 @@ export const Toast: FC = ({ data, config }) => { }; useEffect(() => { - if (!!toast.message) handleAnimation(); - }, [toast.message, toastHeight]); + if (isValidToast) handleAnimation(); + }, [toast.message, toast.title, toastHeight]); useEffect(() => { - if (!!data.message.length) { + if (data.message || data.title) { setToast({ title: data.title, message: data.message, @@ -315,7 +317,7 @@ export const Toast: FC = ({ data, config }) => { }, }); - return toast?.message?.length > 0 ? ( + return isValidToast ? ( = ({ data, config }) => { config?.customIcon[toast.type]} - {!!data.title && ( + {!!data.title?.trim() && ( = ({ data, config }) => { )} - {data.message && ( + {data.message?.trim() && ( ` font-weight: ${fontWeight}; font-family: ${({ fontFamily }) => fontFamily ?? fontDefault}; color: ${({ textColor }) => textColor ?? '#fff'}; - margin-bottom: 12px; `; export const Message = styled.Text`