Skip to content
Merged
Changes from 1 commit
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
14 changes: 6 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,10 @@ export async function MarkdownAsync(options) {
* React node.
*/
export function MarkdownHooks(options) {
const processor = createProcessor(options)
const processor = useMemo(
() => createProcessor(options),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use a regular function, thanks

[options.rehypePlugins, options.remarkPlugins, options.remarkRehypeOptions]
)
const [error, setError] = useState(
/** @type {Error | undefined} */ (undefined)
)
Expand All @@ -238,12 +241,7 @@ export function MarkdownHooks(options) {
cancelled = true
}
},
[
options.children,
options.rehypePlugins,
options.remarkPlugins,
options.remarkRehypeOptions
]
[options.children, processor]
)

if (error) throw error
Expand Down