0.0.3 • Published 1 year ago

eykmodal v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Eyk-modal Library

This package is a module that helps you easily create modals using React.

How to install

npm i eykmodal

How to use

import { Modal } from "eykmodal";

export default function DetailModal() {
  return (
    <Modal>
      //contents what you want to put in modal
      <div>"HELLO"</div>
    </Modal>
  );
}

import { useModal } from "eykmodal";
import DetailModal from "./DetailModal";

function App() {
  const { openModal } = useModal();
  const handleOnclick = () => {
    openModal();
  };

  return (
    <div className="App">
      <button onClick={handleOnclick}>OPEN MODAL</button>
      <DetailModal />
    </div>
  );
}

useModal Hook

const { isModalOpen, openModal, closeModal } = useModal();
FunctionDescription
useModalInitializes the modal state and dispatch functions.
isModalOpenA boolean value that determines if the modal is currently open or closed.
openModalA function that sets the isModalOpen value to true, which opens the modal.
closeModalA function that sets the isModalOpen value to false, which closes the modal.