Skip to content

Commit 8b3ebb9

Browse files
committed
simplify preact flex render types
1 parent f64aea1 commit 8b3ebb9

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

examples/preact/sorting/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function App() {
6464
{
6565
accessorKey: 'progress',
6666
header: 'Profile Progress',
67-
// enableSorting: false, //disable sorting for this column
67+
// enableSorting: false, // disable sorting for this column
6868
},
6969
{
7070
accessorKey: 'rank',

packages/preact-table/src/FlexRender.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import type { ComponentType, VNode } from 'preact'
1+
import type { ComponentChild, ComponentType } from 'preact'
22

3-
export type Renderable<TProps> =
4-
| VNode<TProps>
5-
| ComponentType<TProps>
6-
| undefined
7-
| null
8-
| string
9-
| number
10-
| boolean
3+
export type Renderable<TProps> = ComponentChild | ComponentType<TProps>
114

125
function isPreactComponent<TProps>(
136
component: unknown,
@@ -46,11 +39,11 @@ function isExoticComponent(component: any) {
4639
export function flexRender<TProps extends object>(
4740
Comp: Renderable<TProps> | null,
4841
props: TProps,
49-
): VNode<TProps> | Element | null {
42+
): ComponentChild | Element | null {
5043
return !Comp ? null : isPreactComponent<TProps>(Comp) ? (
5144
<Comp {...props} />
5245
) : (
53-
(Comp as VNode<TProps> | Element | null)
46+
Comp
5447
)
5548
}
5649

0 commit comments

Comments
 (0)