Skip to content

onComplete in MarkdownHooks #912

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

Open
4 tasks done
BlackRam-oss opened this issue May 5, 2025 · 1 comment · May be fixed by #913
Open
4 tasks done

onComplete in MarkdownHooks #912

BlackRam-oss opened this issue May 5, 2025 · 1 comment · May be fixed by #913
Labels
🤞 phase/open Post is being triaged manually

Comments

@BlackRam-oss
Copy link

BlackRam-oss commented May 5, 2025

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>
@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 5, 2025
@BlackRam-oss
Copy link
Author

Since I saw that it is really simple to add it, I tried to add it directly myself: #913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually
Development

Successfully merging a pull request may close this issue.

1 participant