1.0.4 • Published 5 years ago

@apagoinc/react-modal-hooks v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago