Skip to content

Commit ed4d41e

Browse files
teallarsonclaude
andcommitted
Fix TypeScript error: use React.ElementType for MDX component cache
`React.ComponentType<{ components?: ... }>` was incompatible with `MDXContent` returned by @mdx-js/mdx's evaluate(), due to React 19 components returning ReactNode (including undefined) while @types/mdx expects Element | null. Using React.ElementType resolves the boundary without type suppressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3d8eace commit ed4d41e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

app/_components/toolkit-docs/components/documentation-chunk-renderer.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,14 @@ const MDX_COMPONENTS = {
112112
// Maximum number of MDX components to cache to prevent unbounded memory growth
113113
const MDX_CACHE_MAX_SIZE = 100;
114114

115-
const mdxCache =
116-
createMdxCache<React.ComponentType<{ components?: typeof MDX_COMPONENTS }>>(
117-
MDX_CACHE_MAX_SIZE
118-
);
115+
const mdxCache = createMdxCache<React.ElementType>(MDX_CACHE_MAX_SIZE);
119116

120117
/**
121118
* Renders MDX content from a string with custom components.
122119
*/
123120
function MdxContent({ content }: { content: string }) {
124121
const source = useMemo(() => stripMdxImports(content), [content]);
125-
const [Component, setComponent] = useState<React.ComponentType<{
126-
components?: typeof MDX_COMPONENTS;
127-
}> | null>(null);
122+
const [Component, setComponent] = useState<React.ElementType | null>(null);
128123
const [error, setError] = useState<string | null>(null);
129124

130125
useEffect(() => {

0 commit comments

Comments
 (0)