Skip to content

Instantly share code, notes, and snippets.

@cramforce
Created October 26, 2022 21:19
  • Star 71 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cramforce/b5e3f0b103f841d2e5e429b1d5ac4ded to your computer and use it in GitHub Desktop.
function asyncComponent<T, R>(fn: (arg: T) => Promise<R>): (arg: T) => R {
return fn as (arg: T) => R;
}
const Delay = asyncComponent(async ({ ms }: { ms: number }) => {
const one = await delay(String(ms), ms);
return <p>{one}</p>;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment