JSPM

  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q62481F
  • License MIT

Lightweight hooks ready dialogs management

Package Exports

  • react-dialogs-container
  • react-dialogs-container/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-dialogs-container) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-dialogs-container

Library for manage dialogs inside application

Install

npm i react-dialogs-container

Setup:

  • Place DialogsProvider over your application
  • Place DialogsContainer inside your application

Example to use

const App = () => {
  const { pushDialog } = useDialogsContainer();

  return (
    <button onClick={() => pushDialog(ModalComponent, { taste: "So tasty" })}>
      Open Modal
    </button>
  );
};

const Root = () => (
  <DialogsProvider>
    <App />
    <DialogsContainer />
  </DialogsProvider>
);

API

Hooks

useDialogsContainer
pushDialog(component, props): number - push new dialog component, return dialog identificator
closeDialogByID(dialogID) - close dialog by identificator
useDialog - return methods base on inherited context
closeDialog - fucntion to close dialog

Example usage on CodeSandbox

Edit Example usage of react-dialogs-container