1.0.8 • Published 4 years ago

fancy-react-modal v1.0.8

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

fancy-react-modal

modal dialog for React.JS

npm.io

install

$ npm install fancy-react-modal  
$ yarn install fancy-react-modal

example

Parent Component

import React, { FC } from 'react';
import Modal from 'fancy-react-modal';
import Alert, { IAlertProps, IAlertResult } from './components/alert';

const Parent = () => {

  const openModal = () => {
    Modal.open<IAlertProps, IAlertResult>(Alert, {}).then((result: IAlertResult) => {
      // after modal component dismiss function
    }).catch(() => {
      // after click modal background
    });
  }

  return (
    <>
      <button onClick={() => {openModal()}}>open</button>
    </>
  )
}
Modal Component

import React, { FC } from 'react';
import { IBaseModalProps } from 'fancy-react-modal';

interface IAlertModalProps extends IBaseModalProps<IAlertResult> {}

interface IAlertModalResult {}

const Alert: FC<IAlertModalProps> = ({ dismiss }) => {

  return (
    <>
      <div>
        Hi I am Modal
        <button onClick={() => {dismiss()}}>close</button>
      </div>
    </>
  )
}
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago