@apagoinc/react-modal-hooks

Made with create-react-library

Usage no npm install needed!

<script type="module">
  import apagoincReactModalHooks from 'https://cdn.skypack.dev/@apagoinc/react-modal-hooks';
</script>

README

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