react-markdown icon indicating copy to clipboard operation
react-markdown copied to clipboard

onComplete in MarkdownHooks

Open BlackRam-oss opened this issue 8 months ago • 1 comments

Initial checklist

Problem

Hi, I'm the developer of react-markdown-typewriter a library that adds elements that give the possibility to animate each letter of the markdown component, by default, to create a typewriter animation. the animations are created with motion.

For now I have created the variants for the Markdown and MarkdownAsync components.

I'm trying to create the variant for MarkdownHooks too.

Roughly how it works is the following, a parent component (motion) starts the animation of each child (Markdown elements) every n milliseconds. the animation must be triggered by an event for example during the first render.

With MarkdownHooks if I trigger the animation during the first render it will be executed on the fallback element and not when the MarkdownHooks element has finished loading.

So I would need a function (onComplete) that warns me that the MarkdownHooks loading is finished and then triggers the animation.

Current solutions

I've currently solved it this way, although it can't be considered a solution 😒

    useEffect(() => {
        setTimeout(() => {
            // start animation
        }, 10);
    }, [text]);

Proposed solutions

add a function that is launched when markdown loading is finished

            <MarkdownHooks
                onComplete={() => {
                      // start animation
}}
            >
                {text}
            </MarkdownHooks>

BlackRam-oss avatar May 05 '25 20:05 BlackRam-oss

Since I saw that it is really simple to add it, I tried to add it directly myself: https://github.com/remarkjs/react-markdown/pull/913

BlackRam-oss avatar May 06 '25 17:05 BlackRam-oss

Closing, see https://github.com/remarkjs/react-markdown/pull/913#issuecomment-3549253114

wooorm avatar Nov 18 '25 19:11 wooorm

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

github-actions[bot] avatar Nov 18 '25 19:11 github-actions[bot]