overleaf/services/web/frontend/js/shared/components/polymorphic-component.tsx
ilkin-overleaf 2f803292b4 Merge pull request #16857 from overleaf/ii-share-modal-click
[web] Clickable share modal buttons

GitOrigin-RevId: db6bef9b63e98007741d88b291a282d6ea4a68c5
2024-02-06 09:03:40 +00:00

19 lines
513 B
TypeScript

import { MergeAndOverride } from '../../../../types/utils'
type PolymorphicComponentOwnProps<E extends React.ElementType> = {
as?: E
}
export type PolymorphicComponentProps<E extends React.ElementType> =
MergeAndOverride<React.ComponentProps<E>, PolymorphicComponentOwnProps<E>>
function PolymorphicComponent<E extends React.ElementType = 'div'>({
as,
...props
}: PolymorphicComponentProps<E>) {
const Component = as || 'div'
return <Component {...props} />
}
export default PolymorphicComponent