Simple Modal working with React
Install react-modal with npm
npm i @fsmnk/react-modal
import Modal from '@fsmnk/react-modal';
const App = () => {
return (
<div className="App">
<Modal>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</Modal>
</div>
);
};
export default App;
Name | Required | Default | Type | Example |
---|---|---|---|---|
title | no | undefined | string | Click |
onOpen | no | undefined | function | Click |
onClose | no | undefined | function | Click |
onCreate | no | undefined | function | Click |
onFocus | no | undefined | function | Click |
import Modal from '@fsmnk/react-modal';
const App = () => {
return (
<div className="App">
<Modal title="Lorem ipsum">...</Modal>
</div>
);
};
export default App;
onOpen
trigger when menu is opened
<Modal onOpen={() => console.log('onOpen')}>...</Modal>
onClose
trigger when menu is closed
<Modal onClose={() => console.log('onClose')}>...</Modal>
onCreate
trigger when component is create
<Modal onCreate={() => console.log('onCreate')}>...</Modal>
onFocus
trigger when input is focused