Skip to content

Instantly share code, notes, and snippets.

@cramforce
Created October 26, 2022 21:19
  • Star 72 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
Embed
What would you like to do?
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