1.0.4 • Published 5 years ago
@apagoinc/react-modal-hooks v1.0.4
react-modal-hooks
Because everyone is bad except for me
Install
npm install @apagoinc/react-modal-hooks
Usage
import React from 'react'
import 'react-modal-hooks/dist/index.css'
import { ModalBody, useModal, ModalProps } from 'react-modal-hooks/dist'
interface TestModalProps {
title: string;
}
const TestModal = (props: TestModalProps & ModalProps) => {
return (
<ModalBody>
<h1>{props.title}</h1>
<button onClick={props.onClose}>Close</button>
</ModalBody>
);
}
const App = () => {
const { openModal, modal } = useModal<TestModalProps>(TestModal);
const openTestModal = () => {
openModal({
title: 'This is a test modal'
});
}
return (
<div>
{modal}
<h1>React Modal Hooks Demo</h1>
<button onClick={openTestModal}>Open Modal</button>
</div>
)
}
export default App
License
MIT © yeager-j