React alternative to window.prompt() using MUI
npm install use-prompt-mui
<PromptProvider>
<App />
</PromptProvider>
const ExampleButton = () => {
const prompt = usePrompt()
return <button onClick={async () =>
const message = await prompt.show({
title: "Enter your message",
})
if (message !== null) {
console.log(message)
}
}>
Push me
</button>
}
interface PromptOptions {
title: string
message?: string
initialText?: string
okText?: string
cancelText?: string
}