react-modal-patrick
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

🙆‍♂️ react-modal-patrick 🙆‍♂️

I'm Patrick. This is the first package I uploaded. I recommend you use this when you need modals while using React. You can turn on the modal with one click and simply turn it off by pressing the background or esc button.

Table of Contents

Installation

# using npm
$ npm install --save react-modal-patrick

# using yarn
$ yarn add react-modal-patrick

Import components

import { ModalPortal,
         ModalContext, 
         useModalContext, 
         ModalContextProvider } 
from 'react-modal-patrick';

Setup

You need to use a ModalContextProvider to cover components that need to use modals.

import { ModalContextProvider } from 'react-modal-patrick';

const App = () => {
  return (
    <ModalContextProvider>
      <your component>
    </ModalContextProvider>
  );
};

Examples

Here is a simple example of react-modal-patrick being used in an app.

patrick modal 실행

import { useModalContext, ModalPortal } from 'react-modal-patrick';

export const Modal= {
    const { isModalOpen, openModal, closeModal } = useModalContext();
    return (
      <>
        <button onClick={openModal}>Open Modal</button>
        {isModalOpen && (
          <ModalPortal closeModalHandler={closeModal}>
            <>
                <p>
                Hello. I'm Patrick. I hope you like this  package.
                </p>
                <button onClick={closeModal}>Close Modal</button>
            </>
          </ModalPortal>
        )}
      </>
    );
};

ModalPortal Props

children

Prop expects a single child of type 'ReactChild'. It should be ReactChild type.

Thank you. Have a good day! 😄

Package Sidebar

Install

npm i react-modal-patrick

Weekly Downloads

0

Version

0.0.9

License

none

Unpacked Size

7.26 kB

Total Files

4

Last publish

Collaborators

  • geuncheolpark