Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 1.43 KB

README.md

File metadata and controls

68 lines (57 loc) · 1.43 KB

React Native Dialog


Content

  1. Props
  2. Importing the component
  3. Usage example

Props

The component has multiple props, which two on them are required

  • onClose - A void callback function than executes when dialog will close.
  • open - A boolean variable that indicates when the dialog is open.

An optional children, anything that will be inside your dialog component.

  • children - An any type variable. This will be inside your dialog tag.

The rest of props are dialog tag attributes (HTMLDialogAttributes).


Importing the component

import Dialog from 'native-react-modal';

Usage example

dialog-example

//React
import React from 'react';

//Components
import Dialog from 'native-react-modal';

//Your component
const SomeComponent = () => {

  //...

  //States
  const [isOpen, setIsOpen] = React.useState<boolean>(false);

  //Handlers
  conts closeDialogHandler = () => {
    setIsOpen(false);
  }
  
  conts openDialogHandler = () => {
    setIsOpen(true);
  }

  //...

  return (
    <>
      <button
        onClose={openDialogHandler}
      >
        Open dialog!
      </button>
      <Dialog
        onClose={closeDialogHandler}
        open={isOpen}
      >
        This is a dialog!
      </Dialog>
    </>
  );
}