From 1c29c32be3f2e87a89877f5619a8420d83550acb Mon Sep 17 00:00:00 2001 From: Mark Kaliada Date: Sat, 2 Mar 2024 02:54:09 +0300 Subject: [PATCH] Add support for RSC by removing useRef usage --- src/Markdown.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Markdown.ts b/src/Markdown.ts index f8ea096..5b7bf21 100644 --- a/src/Markdown.ts +++ b/src/Markdown.ts @@ -1,4 +1,4 @@ -import { createElement, Fragment, useRef } from 'react'; +import { createElement, Fragment } from 'react'; import { Marked, MarkedOptions } from 'marked'; import ReactParser from './ReactParser'; @@ -33,11 +33,13 @@ const defaultProps = { renderer: undefined, }; +const markedInstance = new Marked(); + const Markdown = (props: MarkdownProps) => { validateComponentProps(props); const options = { ...defaultProps, ...props }; - const { current: marked } = useRef(options.instance ?? new Marked()); + const marked = options.instance ?? markedInstance; // lexer options const lexerOptions = {