@backpackapp-io/react-native-toast
Version:
A toasting library for React Native. Built in features such as swipe to dismiss, multiple toasts, & no context power this library.
18 lines (17 loc) • 505 B
JavaScript
;
import { useEffect, useState } from 'react';
export const useVisibilityChange = (onShow, onHide, visible, dismissReason) => {
const [mounted, setMounted] = useState(false);
useEffect(() => {
if (!mounted && visible) {
setMounted(true);
onShow();
}
if (mounted && !visible) {
setMounted(false);
onHide(dismissReason);
}
}, [visible, mounted, dismissReason, onShow, onHide]);
return undefined;
};
//# sourceMappingURL=useVisibilityChange.js.map