modals-controller-react
v0.0.2
Published
Modals controller with react
Downloads
1
Readme
modals-controller-react
Modals controller with react
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