Small preact-based (like React.js) project https://inga-lovinde.github.io/static/komoot-demo/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

13 lines
363 B

import { useCallback } from 'preact/hooks';
export const usePrompt = (
message: string,
defaultValue: string,
onChange: (newValue: string) => void,
) =>
useCallback(() => {
const newValue = prompt(message, defaultValue);
if (newValue?.length) {
onChange(newValue);
}
}, [message, defaultValue, onChange]);