parent
e6bf07cbd0
commit
47b2aeb48b
@ -0,0 +1,14 @@ |
||||
import { useCallback } from 'preact/hooks'; |
||||
|
||||
export const usePrompt = ( |
||||
message: string, |
||||
defaultValue: string, |
||||
onChange: (newValue: string) => void, |
||||
) => { |
||||
return useCallback(() => { |
||||
const newValue = prompt(message, defaultValue); |
||||
if (newValue?.length) { |
||||
onChange(newValue); |
||||
} |
||||
}, [message, defaultValue, onChange]); |
||||
}; |
Loading…
Reference in new issue