1.0.1 • Published 6 months ago
simple-modal-react-component-v2 v1.0.1
simple-modal-react-component-v2
A simple modal component in React
Prerequisites
These are the dependencies along with their recommended versions:
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