mirror of
https://github.com/ershisan99/podcaster.git
synced 2025-12-16 20:59:26 +00:00
fix: Wrap props typing
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
import { createElement, ReactNode } from "react";
|
||||
import {
|
||||
ComponentPropsWithoutRef,
|
||||
createElement,
|
||||
ElementType,
|
||||
ReactNode,
|
||||
} from "react";
|
||||
|
||||
type Props = {
|
||||
type Props<T extends ElementType> = {
|
||||
if?: boolean;
|
||||
with: Parameters<typeof createElement>[0];
|
||||
wrapperProps: Parameters<typeof createElement>[1];
|
||||
with: T;
|
||||
wrapperProps: ComponentPropsWithoutRef<T>;
|
||||
children: NonNullable<ReactNode>;
|
||||
};
|
||||
|
||||
export function Wrap({
|
||||
export function Wrap<T extends ElementType>({
|
||||
if: condition,
|
||||
with: wrapper,
|
||||
wrapperProps,
|
||||
children,
|
||||
}: Props) {
|
||||
}: Props<T>) {
|
||||
return condition ? (
|
||||
createElement(wrapper, wrapperProps, [children])
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user