npm-react-modal-mehdizi
v0.1.4
Published
A simple react modal component
Readme
TypeScript Components by Rupert
A simple react modal component
This repository was created as part of a guide to publishing TypeScript React components. You can read the guide over here: Publishing TypeScript React components to NPM
Getting Started
Install this package:
npm i npm-react-modal-mehdiziImport the Modal component:
import { Modal, useModal } from "npm-react-modal-mehdizi";import the variable and the function to handle the modal into your component.
const { isOpen, handleToggleModal } = useModal();You can then render the Modal component like any other React component in JSX.
with the message props of your choice :
<Modal
message="Message of your choice !"
isOpen={isOpen}
handleCloseModal={handleToggleModal}
/>Apply the handleToggleModal to the button of your choice on the onClick method
<Button onClick={handleToggleModal}>Toggle modal here !<Button>