
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-dialog-hook
Advanced tools
This hook was made to manage dialog state in React. The main feature is a possibility to get results passed as an argument of the close method as a returned value from the open dialog method. See example.
All data (params and results) are also available as returned object keys from the hook.
It's fully written in Typescript.
npm i react-dialog-hook
import { useDialog } from "react-dialog-hook";
It is possible to use already prepared context for dialog:
import { DialogConsumer, DialogProvider, DialogContext } from "react-dialog-hook";
Live demo in codesandbox is available here: https://codesandbox.io/s/react-dialog-hook-demo-b99uy?file=/src/App.tsx
import { useDialog } from "react-hook-dialog";
function Dialog({ isOpen, close, params }) {
const dialogResult = "RESULT"
return (
<>
{isOpen && (
<div>
<h1>DIALOG HEADER</h1>
<button onClick={() => close(dialogResult)}>close</button>
</div>
)}
</>
)
}
function Example() {
const {
isOpen
open
close
params,
results
} = useDialog<ParamsType, ResultsType>({
isDefaultOpen: false; // Set dialog open after first render
});
const openHandler = useCallback(async () => {
const dialogParams = "PARAM"
const resultsFromDialog = await open(dialogParams); // It returns results passed as argument to close method
}, []);
return (
<>
<button onClick={openHandler}>OPEN DIALOG</button>
<Dialog isOpen={isOpen} close={close} params={params} />
</>
)
}
| Key | Default | Description |
|---|---|---|
| isDefaultOpen | false | Allows opening dialog on the first render without the user's intervention. |
| Key | Type | Description |
|---|---|---|
| isOpen | boolean | Opening state of dialog |
| params | any | Params which can be passed into hook via open method. |
| results | any | Results passed into close method accesible via this key and also as returned value from open method. |
| open | async (params) => results | Method which change dialog state to open and set params passed as argument. Returns results which were set from close method. |
| close | async (results) => void | Method which change dialog state to close and set results passed as argument. |
To report a bug connected with lib, please open a new issue, assign one of the authors into it and add the bug label.
If you have any idea how to improve this lib, please fork this repo, suggest changes, make a PR and add one of the authors as a reviewer. Don't forget to add a proper description of this feature/bugfix.
Hubert Stemplewski | Benedykt Dryl | Witold Mętel |
FAQs
React hook for manage dialogs state
We found that react-dialog-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.