Skip to content

Commit

Permalink
Widen ReactChild to ReactNode for React 19 type compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mrginglymus committed Dec 16, 2024
1 parent 1accd8e commit 9c810b7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ function reactFor(render) {
return function patchedRender(
ast: MarkdownToJSX.ParserResult | MarkdownToJSX.ParserResult[],
state: MarkdownToJSX.State = {}
): React.ReactChild[] {
): React.ReactNode[] {
if (Array.isArray(ast)) {
const oldKey = state.key
const result = []
Expand Down Expand Up @@ -1094,7 +1094,7 @@ function createRenderer(
ast: MarkdownToJSX.ParserResult,
render: MarkdownToJSX.RuleOutput,
state: MarkdownToJSX.State
): React.ReactChild {
): React.ReactNode {
const renderer = rules[ast.type].render as MarkdownToJSX.Rule['render']

return userRender
Expand Down Expand Up @@ -2292,7 +2292,7 @@ export namespace MarkdownToJSX {
*/
render: RuleOutput,
state?: MarkdownToJSX.State
) => React.ReactChild
) => React.ReactNode
}

export type Rules = {
Expand Down Expand Up @@ -2321,8 +2321,8 @@ export namespace MarkdownToJSX {
createElement: (
tag: Parameters<CreateElement>[0],
props: React.JSX.IntrinsicAttributes,
...children: React.ReactChild[]
) => React.ReactChild
...children: React.ReactNode[]
) => React.ReactNode

/**
* The library automatically generates an anchor tag for bare URLs included in the markdown
Expand Down Expand Up @@ -2414,14 +2414,14 @@ export namespace MarkdownToJSX {
*/
renderRule: (
/** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */
next: () => React.ReactChild,
next: () => React.ReactNode,
/** the current AST node, use `RuleType` against `node.type` for identification */
node: ParserResult,
/** use as `renderChildren(node.children)` for block nodes */
renderChildren: RuleOutput,
/** contains `key` which should be supplied to the topmost JSX element */
state: State
) => React.ReactChild
) => React.ReactNode

/**
* Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library export called `sanitizer`.
Expand Down

0 comments on commit 9c810b7

Please sign in to comment.