0.0.2 • Published 4 years ago

modals-controller-react v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

modals-controller-react

Modals controller with react

NPM JavaScript Style Guide

Install

npm install --save modals-controller-react

Usage

import React, { Component } from 'react'

import * as ModalsController from 'modals-controller-react';

const Example = () => (
  <ModalsController.Provider>
    <ExampleComponent1>
  </ModalsController.Provider>
);
import { useModalController } from 'modals-controller-react';

const modalId = 'MODAL_TEST_ID';
const {
  isOpen,
  getConfigs,
  open,
  close,
  updateConfig
} = useModalController();

// check if modal is open
const modalIsOpen = isOpen(modalId);

// gets modal config
const modalConfigs = getConfigs(modalId);

// function to open a specific modal
open(modalId, {values: {foo: 'bar'}});

// function to close a specific modal
close(modalId);

// function to update the settings of a modal
updateConfig(modalId, {newValues: {}});

};

License

MIT © claudiohilario