Skip to content

Commit

Permalink
refactor(minor): re-initialize parser when styles, baseUrl prop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsgowtham committed Feb 18, 2023
1 parent 772abbd commit 3bc3979
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ const Markdown = ({
[userStyles, colorScheme, theme],
);

const parser = useMemo(
() => new Parser({ styles, baseUrl }),
[styles, baseUrl],
);

const rnElements = useMemo(() => {
const parser = new Parser({ styles, baseUrl });
const tokens = marked.lexer(value, { mangle: false, gfm: true });
return parser.parse(tokens);
}, [value, styles, baseUrl]);
Expand Down

0 comments on commit 3bc3979

Please sign in to comment.