react-hooks-modal

React Hooks for Modal

Usage no npm install needed!

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

README

react-hooks-modal

NPMVersion

React Hooks for Modal

Install

npm i react-hooks-modal

The Gist

import { useModal } from 'react-hooks-modal'
import { Button, Modal } from 'antd'

function App() {
  const { visible, show, hide } = useModal()
  return (
    <Button onClick={show}>Show Modal</Button>
    <React.Fragment>
      <Modal
        visible={visible}
        onClose={hide}
      >
        <span>A modal</span>
      </Modal>
    </React.Fragment>
  )
}

License

MIT © Randy