react-native-modal-2
Version:
A powerful, customizable modal library for React Native with smooth animations, touchable backdrop, and comprehensive TypeScript support.
27 lines (26 loc) • 792 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
/**
* A hook to manage modal visibility state
* @returns {UseModalResult} An object containing the modal state and functions to control it
*/
const useModal = (initialState = false) => {
const [visible, setVisible] = (0, react_1.useState)(initialState);
const showModal = (0, react_1.useCallback)(() => {
setVisible(true);
}, []);
const hideModal = (0, react_1.useCallback)(() => {
setVisible(false);
}, []);
const toggleModal = (0, react_1.useCallback)(() => {
setVisible((prev) => !prev);
}, []);
return {
visible,
showModal,
hideModal,
toggleModal,
};
};
exports.default = useModal;
;