Skip to content
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

When providing a streaming content, everything re-renders all the time #32

Closed
baptisteArno opened this issue Apr 10, 2024 · 1 comment
Closed

Comments

@baptisteArno
Copy link

One thing that is cool with react-markdown is that even if you provide a content that is being streamed, what was already added to the DOM won't re-rendered again, allowing the user to interact with the existing text while the content is being streamed.

It seems this does not work the same with solid-markdown.

Reproduction:

export const StreamingBubble = (props: Props) => {
  const [content, setContent] = createSignal<string>('')

  onMount(() => {
    setInterval(() => {
      setContent(content => content + 'new content')
    }, 100)
  })

  return <SolidMarkdown children={content()} />
}

If you select the text, whenever the component re-renders, the selection will be removed.

@andi23rosca
Copy link
Owner

andi23rosca commented May 4, 2024

Hey @baptisteArno, just fixed this in v2.0.3, there's now a renderingStrategy prop, you can pass "reconcile" to, to make it diff the ASTs and only re-render the parts of the DOM that changed.

See https://github.com/andi23rosca/solid-markdown?tab=readme-ov-file#rendering-strategy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants