
Product
Introducing Socket Scanning for OpenVSX Extensions
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
@byteclaw/use-prompt
Advanced tools
React hook and component for prompting the user to input anything using your custom components
React hook and component for prompting the user to input anything using your custom components.
npm install @byteclaw/use-prompt
yarn add @byteclaw/use-prompt
Here is a quick example. answer accepts any values you want so you aren't limited just to boolean values.
By default application uses global event emitter context created by @byteclaw/use-event-emitter hook unless you create your own event emitter context.
import { Prompts, usePrompt } from '@byteclaw/use-prompt';
import React, { useCallback } from 'react';
function Dialog({ onAccept, onReject }) {
return (
<div>
<p>Are you sure?</p>
<button onClick={onAccept}>Yes</button>
<button onClick={onReject}>No</button>
</div>
);
}
function ConfirmButton() {
const [prompt, prompting] = usePrompt();
const onClick = useCallback(async () => {
const result = await prompt(({ answer }) => (
<Dialog onAccept={() => answer(true)} onReject={() => answer(false)} />
));
}, [ask]);
return (
<button disabled={prompting} onClick={onClick}>
Do something
</button>
);
}
function App() {
return (
<>
<ConfirmButton />
<Prompts />
</>
);
}
import {
EventEmitterContext,
useEventEmitterInstance,
} from '@byteclaw/use-event-emitter';
import { Prompts, usePrompt } from '@byteclaw/use-prompt';
import React, { useCallback } from 'react';
function Dialog({ onAccept, onReject }) {
return (
<div>
<p>Are you sure?</p>
<button onClick={onAccept}>Yes</button>
<button onClick={onReject}>No</button>
</div>
);
}
function ConfirmButton() {
const [prompt, prompting] = usePrompt();
const onClick = useCallback(async () => {
const result = await prompt(({ answer }) => (
<Dialog onAccept={() => answer(true)} onReject={() => answer(false)} />
));
}, [ask]);
return (
<button disabled={prompting} onClick={onClick}>
Do something
</button>
);
}
function App() {
const eventEmitter = useEventEmitterInstance();
return (
<EventEmitterContext.Provider value={eventEmitter}>
<ConfirmButton />
<Prompts />
</EventEmitterContext.Provider>
);
}
FAQs
React hook and component for prompting the user to input anything using your custom components
We found that @byteclaw/use-prompt 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.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies