1.0.2 • Published 2 years ago

mm-simple-modal v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mm-simple-modal

Made with create-react-library

NPM JavaScript Style Guide

https://www.npmjs.com/package/mm-simple-modal

Install

npm install --save mm-simple-modal

Usage

This is a simple example of mm-simple-modal. You have to set a state for the modal and closeModal function in the parent component.

import React, { useState } from 'react'

import Modal from 'mm-simple-modal'
import 'mm-simple-modal/dist/index.css'

const App = () => {
  const [showModal, setShowModal] = useState(false)

  const closeModal = () => {
    showModal && setShowModal(false)
  }

  return (
    <div className='App'>
      <h1>React Modal</h1>
      <button className='btn' onClick={() => setShowModal(true)}>
        show Modal
      </button>
      <Modal show={showModal} onCloseModal={closeModal}>
        Message in Modal
      </Modal>
    </div>
  )
}

Props

PropsTypeRequiredDefaultDescription
showBoolRequiredFalseState allows you to display the modal
onCloseModalFunctionRequired-Function allows you to remove the modal
childrenStringRequired-Add content modal

License

MIT © MouniaFT