Modal pluggin for project 14 : Pass a jQuery library to React
A simple react modal (conversion of the jquery modal)
Install simple-react-modal with npm:
npm i simple-fade-modal
import { Modal } from 'simple-fade-modal';
function MyModal() {
const [modalState, setModalState] = useState(false);
const toggle = () => {
setModalState((prev) => !prev);
};
return (
<>
<button onClick={toggle}>Save</button>
<Modal toggleModal={toggle} modalState={modalState}>
I'm the content
</Modal>
</>
);
}
const myContentStyle = {
fontSize: '1.25rem',
color: 'red',
background: 'beige',
};
<Modal toggleModal={toggle} modalState={modalState} fadeDuration="200ms" contentStyle={myContentStyle} />;
//fadeDuration is 400ms by default