Skip to content

Commit 456ed50

Browse files
authored
Merge pull request #137 from chhsiao1981/thunk-context-as-jsx-element
ThunkContext as JSX.Element
2 parents 7487e6d + 924d378 commit 456ed50

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/ThunkContext.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { type ReactElement, useMemo, useState } from 'react'
1+
import { type JSX, useMemo, useState } from 'react'
22
import type { ClassState } from './stateTypes'
33
import { THUNK_CONTEXT_MAP } from './thunkContextMap'
44

55
type Props = {
66
classes?: string[]
7-
children: ReactElement
7+
children?: JSX.Element
88
}
9-
const ThunkContext = (props: Props): ReactElement => {
9+
const ThunkContext = (props: Props): JSX.Element => {
1010
let { classes, children } = props
1111
if (!classes) {
1212
classes = THUNK_CONTEXT_MAP.theList
1313
}
1414
if (classes.length === 0) {
15+
// @ts-expect-error with children
1516
return children
1617
}
1718

types/ThunkContext.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { type ReactNode } from 'react';
1+
import { type JSX } from 'react';
22
type Props = {
33
classes?: string[];
4-
children?: ReactNode;
4+
children?: JSX.Element;
55
};
6-
declare const ThunkContext: (props: Props) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
6+
declare const ThunkContext: (props: Props) => JSX.Element;
77
export default ThunkContext;

0 commit comments

Comments
 (0)