Skip to content

Latest commit

 

History

History
50 lines (41 loc) · 1.41 KB

README.md

File metadata and controls

50 lines (41 loc) · 1.41 KB

simple-modal-react-component-v2

A simple modal component in React

Prerequisites

These are the dependencies along with their recommended versions:
Npm Node React React-DOM Sass

Install

npm i simple-modal-react-component-v2

Usage

import React, { useState } from 'react';
import { Modal } from 'simple-modal-react-component-v2';

function App() {
    const [isOpen, setIsOpen] = useState(false);
    
    return (
        <div>
          <button onClick={() => setIsOpen(true)}>Click to open</button>
          <Modal
                isOpen={isOpen}
                onClose={() => setIsOpen(false)}
                onExternalClick={() => setIsOpen(false)}
            >
                Modal message !
            </Modal>
        </div>
    );
}

export default App;

Properties

  • isOpen (boolean): State of the modal's visibility.
  • onClose (function): Function to call to close the modal.
  • onExternalClick (function): Function to call when clicking outside the modal or its close button when it is open.
  • children (string): Text to display when the modal is open.

License

MIT © cymard