simple-modal-react-component-v2

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i simple-modal-react-component-v2

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

9.36 kB

Total Files

7

Last publish

Collaborators

  • cymard