#Load MDX in a component?

1 messages · Page 1 of 1 (latest)

south basin
#

I'm trying to write my tool tip text in markdown, and I load the tool tip as a component. Because as I understand components don't have a loader, I can't use a loader. How do I load a markdown file from react and display it as a component, inside my tooltip ~/component/Tooltip.tsx so it can work throughout my application? thanks

novel ingot
#

If it's just markdown (and not MDX), then the marked library can parse it and be inserted as inner HTML.

#
import marked from 'marked';


const markdown = `## This is markdown

Some *markdown text* here.`


export const Tooltip () => {

  const html = marked.parse(markdown);

  return <div dangerouslySetInnerHTML={{__html: html}) />
}
#

BTW, if you need to load data from a component, useFetcher.load(route) works.