Created
June 25, 2021 08:16
-
-
Save honzabrecka/3c927ba83fa0d2c9e59f9262385e8eb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ix = 0; | |
const getIx = () => `generated_id/${ix++}` | |
const useGenerateId = () => { | |
const [id, setId] = useState(getIx); | |
const regenerate = useCallback(() => setId(getIx()), []); | |
return [id, regenerate]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment