react-native-tm
Advanced tools
Comparing version 1.0.9 to 1.0.10
{ | ||
"name": "react-native-tm", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"main": "Toast.jsx", | ||
@@ -5,0 +5,0 @@ "description": "Customizable toast component for react-native applications. Supported on ios and android.", |
@@ -11,4 +11,7 @@ import React, {forwardRef, useEffect, useRef} from "react"; | ||
useEffect(() => { | ||
if (!!children && show) | ||
showToast() | ||
if (!!children && show) { | ||
showToast(); | ||
} else { | ||
hide(); | ||
} | ||
},[children, show]); | ||
@@ -24,18 +27,22 @@ | ||
useNativeDriver: true | ||
}).start(() => hideToast()); | ||
} | ||
}).start(() => timeoutHide()); | ||
}; | ||
const hideToast = () => { | ||
const timeoutHide = () => { | ||
clearTimeout(timer.current); | ||
timer.current = setTimeout(() => { | ||
Animated.timing(animatedValue, { | ||
toValue: -animationValue, | ||
duration: 550, | ||
useNativeDriver: true | ||
}).start(() => { | ||
!!onHide && onHide(); | ||
}); | ||
hide(); | ||
}, showingDuration || 8000); | ||
} | ||
}; | ||
const hide = () => { | ||
Animated.timing(animatedValue, { | ||
toValue: -animationValue, | ||
duration: 550, | ||
useNativeDriver: true | ||
}).start(() => { | ||
!!onHide && onHide(); | ||
}); | ||
}; | ||
return( | ||
@@ -42,0 +49,0 @@ <Animated.View |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
9727
4
107
1