npm.io
2.1.0 • Published 4 years ago

@tim-jn/react-modal

Licence
MIT
Version
2.1.0
Deps
11
Size
12 kB
Vulns
0
Weekly
0

@Tim-jn/react-modal

Responsive modal dialog component for React.

Installation

To install, you can use npm or yarn:

$ npm install @tim-jn/react-modal
$ yarn add @tim-jn/react-modal
  • Use <Modal> tag inside your React app.

Exemple


import { Modal } from '@tim-jn/react-modal/dist'
import React from 'react'

export default function Form() {
  window.React = React

  const [isValid, setIsValid] = useState(false)
  
  const handleModalResponse = () => {
    setIsValid(false)
  }

  const handleAddFormSubmit = (e) => {
    e.preventDefault()
    setIsValid(true)
  }

  return (
    <section className="formContent">
      <h2 className="formTitle">Create Employee</h2>
      <form className="form" onSubmit={handleAddFormSubmit}>
        (...)
      </form>
      {isValid ? <Modal text="Employee Created !" handleResponse={handleModalResponse} /> : ''}
    </section>
  )
}

Keywords