Skip to content

Commit 4f8d5d1

Browse files
committed
Create processor in useEffect in MarkdownHooks
In `MarkdownHooks` we don’t need to create the processor for every render. We only need it inside the effect.
1 parent 8545ebd commit 4f8d5d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ export async function MarkdownAsync(options) {
212212
* React node.
213213
*/
214214
export function MarkdownHooks(options) {
215-
const processor = createProcessor(options)
216215
const [error, setError] = useState(
217216
/** @type {Error | undefined} */ (undefined)
218217
)
@@ -221,6 +220,7 @@ export function MarkdownHooks(options) {
221220
useEffect(
222221
function () {
223222
let cancelled = false
223+
const processor = createProcessor(options)
224224
const file = createFile(options)
225225

226226
processor.run(processor.parse(file), file, function (error, tree) {

0 commit comments

Comments
 (0)