Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@vlzh/react-modal-manager
Advanced tools
Readme
Manager for modals in your react application
yarn add @vlzh/react-modal-manager
or
npm add @vlzh/react-modal-manager
You can to manipulate with manager through 2 api:
useModalManager(name: string)
withModalManager(name: string)
⚠️ Info
You can to call
useModalManager
andwithModalManager
with providingname
of modal... but there is one point! When you will providename
you just subscribe current component tomodalManager
+ methods returned fromuseModalManager
will be associated with specific modal.
they provide several methods:
closeModal(name: string): void
- close modal with specific nameopenModal(name: string): void
- open modal with specific nameisOpen(name: string): boolean
- get opening status for modal with specific namegetParams(name: string): boolean
- get opening status for modal with specific nameIn example bellow you can to see, how to subscribe on event. Supported events:
beforeOpen
afterOpen
beforeClose
afterClose
Any provided callback function will call with object like:
{
modal_name: string
}
import React from "react";
import ReactDOM from "react-dom";
import Modal from "react-modal";
import { useModalManager, manager } from "@vlzh/react-modal-manager";
// subscribe on event 'afterOpen'
manager.on("afterOpen", ({ modal_name }) => {
console.log(`Modal ${modal_name} opened`);
});
Modal.setAppElement("#root");
const OpenModalButton = () => {
// if we do not define name in useModalManager this button will not be subscribed on changes in manager, but you must to define modal_name on calling of openModal
const { openModal } = useModalManager();
return (
<button type="button" onClick={() => openModal("example_modal")}>
Open modal
</button>
);
};
const App = (props) => {
const { isOpen, closeModal } = useModalManager("example_modal");
return (
<div>
<OpenModalButton />
<Modal
isOpen={isOpen("example_modal")}
onRequestClose={() => closeModal("example_modal")}
contentLabel="Example Modal"
>
<h2>Hello</h2>
<button onClick={() => closeModal("example_modal")}>
close
</button>
<div>I am a modal</div>
<form>
<input />
<button>tab navigation</button>
<button>stays</button>
<button>inside</button>
<button>the modal</button>
</form>
</Modal>
</div>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
2.0.0
- Support of parametersFAQs
Manager for modals in your react application
The npm package @vlzh/react-modal-manager receives a total of 32 weekly downloads. As such, @vlzh/react-modal-manager popularity was classified as not popular.
We found that @vlzh/react-modal-manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.