Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import {unreachable} from 'devlop'
import {toJsxRuntime} from 'hast-util-to-jsx-runtime'
import {urlAttributes} from 'html-url-attributes'
import {Fragment, jsx, jsxs} from 'react/jsx-runtime'
import {useEffect, useState} from 'react'
import {useEffect, useMemo, useState} from 'react'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import {unified} from 'unified'
Expand Down Expand Up @@ -212,7 +212,12 @@ export async function MarkdownAsync(options) {
* React node.
*/
export function MarkdownHooks(options) {
const processor = createProcessor(options)
const processor = useMemo(
function () {
return createProcessor(options)
},
[options.rehypePlugins, options.remarkPlugins, options.remarkRehypeOptions]
)
const [error, setError] = useState(
/** @type {Error | undefined} */ (undefined)
)
Expand All @@ -238,12 +243,7 @@ export function MarkdownHooks(options) {
cancelled = true
}
},
[
options.children,
options.rehypePlugins,
options.remarkPlugins,
options.remarkRehypeOptions
]
[options.children, processor]
)

if (error) throw error
Expand Down