Skip to content

Commit

Permalink
fix: React 19 type compatibility
Browse files Browse the repository at this point in the history
Closes #583
  • Loading branch information
quantizor committed Nov 20, 2024
1 parent 23caecb commit 918b44b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-ghosts-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'markdown-to-jsx': patch
---

Use newer `React.JSX.*` namespace instead of `JSX.*` for React 19 compatibility.
14 changes: 7 additions & 7 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ export function compiler(
function attrStringToMap(
tag: MarkdownToJSX.HTMLTags,
str: string
): JSX.IntrinsicAttributes {
): React.JSX.IntrinsicAttributes {
const attributes = str.match(ATTR_EXTRACTOR_R)
if (!attributes) {
return null
Expand Down Expand Up @@ -2003,7 +2003,7 @@ const Markdown: React.FC<

return React.cloneElement(
compiler(children, options),
props as JSX.IntrinsicAttributes
props as React.JSX.IntrinsicAttributes
)
}

Expand All @@ -2021,7 +2021,7 @@ export namespace MarkdownToJSX {

export type CreateElement = typeof React.createElement

export type HTMLTags = keyof JSX.IntrinsicElements
export type HTMLTags = keyof React.JSX.IntrinsicElements

export type State = {
/** true if the current content is inside anchor link grammar */
Expand Down Expand Up @@ -2056,7 +2056,7 @@ export namespace MarkdownToJSX {

export interface CodeBlockNode {
type: typeof RuleType.codeBlock
attrs?: JSX.IntrinsicAttributes
attrs?: React.JSX.IntrinsicAttributes
lang?: string
text: string
}
Expand Down Expand Up @@ -2210,7 +2210,7 @@ export namespace MarkdownToJSX {

export interface HTMLNode {
type: typeof RuleType.htmlBlock
attrs: JSX.IntrinsicAttributes
attrs: React.JSX.IntrinsicAttributes
children?: ReturnType<MarkdownToJSX.NestedParser> | undefined
noInnerParse: Boolean
tag: MarkdownToJSX.HTMLTags
Expand All @@ -2219,7 +2219,7 @@ export namespace MarkdownToJSX {

export interface HTMLSelfClosingNode {
type: typeof RuleType.htmlSelfClosing
attrs: JSX.IntrinsicAttributes
attrs: React.JSX.IntrinsicAttributes
tag: string
}

Expand Down Expand Up @@ -2318,7 +2318,7 @@ export namespace MarkdownToJSX {
*/
createElement: (
tag: Parameters<CreateElement>[0],
props: JSX.IntrinsicAttributes,
props: React.JSX.IntrinsicAttributes,
...children: React.ReactChild[]
) => React.ReactChild

Expand Down

0 comments on commit 918b44b

Please sign in to comment.