Skip to content

Instantly share code, notes, and snippets.

View reachtokish's full-sized avatar
💭
Focusing

Kishore reachtokish

💭
Focusing
View GitHub Profile
function CopyButton({ value }) {
let [copied, setCopied] = React.useState();
let hydrated = usePageIsHydrated();
React.useEffect(() => {
let id = setTimeout(() => setCopied(false), 2000);
return () => clearTimeout(id);
}, [copied]);
return (
<button
@gvergnaud
gvergnaud / Promises-under-the-hood.md
Last active June 19, 2024 07:26
Promises, under the hood.

Promises, under the hood

You all know that to create a new Promise you need to define it this way:

  new Promise((resolve, reject) => {
    ...
    resolve(someValue)
  })

You are passing a callback that defines the specific behavior of your promise.