1.0.11 • Published 9 months ago

modal_shiffff v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

ModalConfirm Component

Un composant de modal réutilisable pour React.

Installation

npm i modal_shiffff

Utilisation

import React, { useState } from "react";
import ModalConfirm from "modal_shiffff";

const App = () => {
  const [showModal, setShowModal] = useState(false);

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

  return (
    <div>
      <button onClick={() => setShowModal(true)}>show Modal?</button>
      {showModal && (
        <ModalConfirm text={"Le texte de votre modal"} closeFct={closeModal} />
      )}
    </div>
  );
};

export default App;

Props

  • text (obligatoire) : Le texte à afficher dans la modal.
  • closeFct (obligatoire) : La fonction de rappel qui ferme la modal.

Exemples

Voici un exemple d'utilisation du composant en l'affichant selon le state redux :

import React from "react";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirm from "modal_shiffff";
import { setShowModal } from "../../Feature/modalToggle.slice";

const EmployeeCreate = () => {
  const dispatch = useDispatch();
  const showModal = useSelector((state) => state.ModalToggle.showModal);
  const closeModal = () => {
    dispatch(setShowModal(false));
  };

  return (
    <div>
      {showModal && (
        <ModalConfirm text={"Employee Created!"} closeFct={closeModal} />
      )}
    </div>
  );
};

export default EmployeeCreate;

ScreenShot

Exemple d'image

Node

version: Node.js v18.14.2.

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.2

11 months ago

1.0.0

11 months ago