-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactivity not working. #7
Comments
I have run into the same problem, thank you for the workaround! |
Any update on this? |
Add workaround for - andi23rosca/solid-markdown#7 - andi23rosca/solid-markdown#10
Same here. |
it's 2023 now, still not fixed |
I've not been using this library anymore but #10 might be fixing it. Maybe try out the fork |
Any news on this issue? I know there are a few MD options for Solid but it has come to my attention this is the only one to process it at runtime .. like via component. So hoping to see this was planned to be addressed. |
Ran into the same issue, and ensured reactivity (ab)using the fact that components are "just functions", <div>
{Markdown({
children: markdown(),
})}
</div> |
As the SolidJS ecosystem keeps on growing, I decided yesterday to port my React app to SolidJS. My project extensively uses remarkjs, and this reactivity issue is a big problem for the conversion of my app. In my quest to find a solution, I created a function leveraging the updated rehype-react library, which now supports a plethora of frameworks including SolidJS. Here's the function I developed: import { unified, PluggableList } from "unified"
import remarkParse, { Options as RemarkParseOptions } from "remark-parse"
import remarkRehype, {Options as RemarkRehypeOptions} from "remark-rehype"
import rehypeReact, { Options as RehypeReactOptions } from "rehype-react"
import {Component, createEffect, createSignal, JSX} from "solid-js"
export type MarkdownProps = {
children: string
remarkParseOptions?: RemarkParseOptions
remarkRehypeOptions?: RemarkRehypeOptions
rehypeReactOptions: RehypeReactOptions
rehypePlugins?: PluggableList
remarkPlugins?: PluggableList
}
export const Markdown: Component<MarkdownProps> = (props: MarkdownProps) => {
const [jsxContent, setJsxContent] = createSignal<JSX.Element | null>()
const processor = unified()
.use(remarkParse, props.remarkParseOptions)
.use(props.remarkPlugins || [])
.use(remarkRehype, props.remarkRehypeOptions)
.use(props.rehypePlugins || [])
.use(rehypeReact, props.rehypeReactOptions)
const processMarkdown = (source: string) => {
setJsxContent(processor.processSync(source).result)
}
createEffect(() => {
processMarkdown(props.children)
})
return (
<>
{jsxContent()}
</>
)
} How to Use: In dev : import * as dev from "solid-js/h/jsx-dev-runtime"
<Markdown
children={markdown()}
rehypeReactOptions={{Fragment: dev.Fragment, jsxDEV: dev.jsxDEV, development: true}} /> In production : import * as prod from "solid-js/h/jsx-runtime"
<Markdown
children={markdown()}
rehypeReactOptions={{Fragment: prod.Fragment, jsx: prod.jsx, jsxs: prod.jsxs}} /> I didn't package this in a library because I'm still in the early stages of my SolidJS journey. Maybe someone more experienced can try to use this code as a base? |
@DasLixou 's approach won't work if the When called as a function rather than as used as a JSX component, it's return value is re-evaluated whenever any signal used to call it changes, ensuring the displayed markdown is reactive.
|
i've kind of forgotten about this library and the fact that I don't get GH notification emails didn't help 😓 i'll spend some time this weekend and address the reactivity issues |
forgot to reference the issue in the PR: #25 |
When i use
it doesnt work.
it only works with
please fix this.
The text was updated successfully, but these errors were encountered: