Skip to content

onComplete in MarkdownHooks #912

Open
@BlackRam-oss

Description

@BlackRam-oss

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions