New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-common-modal-module

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-common-modal-module

react common modal module

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

react-common-modal-module

React Context API를 이용한 공통 Modal component 입니다.

Install

npm install react-common-modal-module
# or
yarn add react-common-modal-module

Usage

ContextProvider setting

// root index.jsx or App.jsx...
// ...
import { ModalContextProvider } from "react-common-modal-module";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
    <ModalContextProvider>
        <App />
    </ModalContextProvider>
);

openModal

Modal Contents는 기본 스타일이 적용되어 있지 않으며 중앙정렬이 되어 있습니다.

각각 컴포넌트를 openModal(arg1 : React.ReactNode)을 사용하여 적용합니다.

import { useModal } from "react-common-modal-module";

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

    const handleOpenModal = () => {
        // modal component 커스텀
        // React.ReactNode arg
        openModal(<div>Modal Component</div>);
    };

    return (
        <div>
            <button onClick={handleOpenModal}>open modal</button>
        </div>
    );
}

closeModal

background 배경이 fixed로 적용되어 있으며 배경 클릭시 closeModal이 동작하도록 되어있습니다.

import { useModal } from "react-common-modal-module";

function App() {
    const { openModal, closeModal } = useModal();

    const handleOpenModal = () => {
        // modal component 커스텀
        openModal(
            <div>
                Modal Component
                <button onClick={closeModal}>close modal</button>
            </div>
        );
    };

    return (
        <div>
            <button onClick={handleOpenModal}>open modal</button>
        </div>
    );
}

Issue Reporting

버그를 발견했거나 기능 요청이 있는 경우 Issue 부탁드립니다.

Keywords

react

FAQs

Package last updated on 17 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts