mirror of
https://github.com/ershisan99/podcaster.git
synced 2025-12-17 05:09:27 +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;
|
if?: boolean;
|
||||||
with: Parameters<typeof createElement>[0];
|
with: T;
|
||||||
wrapperProps: Parameters<typeof createElement>[1];
|
wrapperProps: ComponentPropsWithoutRef<T>;
|
||||||
children: NonNullable<ReactNode>;
|
children: NonNullable<ReactNode>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Wrap({
|
export function Wrap<T extends ElementType>({
|
||||||
if: condition,
|
if: condition,
|
||||||
with: wrapper,
|
with: wrapper,
|
||||||
wrapperProps,
|
wrapperProps,
|
||||||
children,
|
children,
|
||||||
}: Props) {
|
}: Props<T>) {
|
||||||
return condition ? (
|
return condition ? (
|
||||||
createElement(wrapper, wrapperProps, [children])
|
createElement(wrapper, wrapperProps, [children])
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user