0.1.11 • Published 2 years ago

opcmodal v0.1.11

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Opcmodal

This project was bootstrapped with Create React App.

Plugin modal pour le projet 14 :

Un modal react simple

  1. Installation
  2. Exemples d'utilisation

Installation

Vous pouvez installer Opcmodal avec npm :

npm install Opcmodal --save

Pour importer le modal : import { Modal } from "opcmodal";

Exemples d'utilisation

// react
import { useState } from "react";
import { Modal } from "opcmodal";

const MyComponent = () => {
  const [isOpen, setIsOpen] = useState(false);

  const openModal = () => {
    setIsOpen(true);
  };

  const closeModal = () => {
    setIsOpen(false);
  };

  return (
    <div onClick={openModal}>{isOpen && <Modal closeModal={closeModal} />}</div>
  );
};

Type par défaut

Modal.propTypes = {
  isOpen: PropTypes.bool,
  openModal: PropTypes.func,
  closeModal: PropTypes.func,
};