Skip to content

Instantly share code, notes, and snippets.

@erikunha
Created September 20, 2022 17:10
Show Gist options
  • Save erikunha/4fdcc1cab8ed8256405cf93b5b87249e to your computer and use it in GitHub Desktop.
Save erikunha/4fdcc1cab8ed8256405cf93b5b87249e to your computer and use it in GitHub Desktop.
Named component
export const namedComponent = async <T, N extends keyof T>(
modPromise: Promise<T>,
exportName: N,
) => {
const mod = await modPromise;
return mod[exportName];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment