tameemsafi / typewriterjs

A simple yet powerful native javascript plugin for a cool typewriter effect.
https://www.npmjs.com/package/typewriter-effect
MIT License
2.49k stars 221 forks source link

Why does it delete the text?? #214

Open bennyschmidt opened 9 months ago

bennyschmidt commented 9 months ago

Possible duplicate: https://github.com/tameemsafi/typewriterjs/issues/162

This is a cool library, but why on earth does it delete the text the moment after it renders?

I can't find an option to make the text simply render without it deleting afterwards.


Edit: I found a solution. Basically, manage your array of strings yourself in React, and you can pass a single string to strings - it doesn't have to be an array.

These will all auto-delete after rendering for some reason:

          <Typewriter
            options={{
              strings: [text]
            }}
          />
          <Typewriter
            options={{
              strings: [text, ""]
            }}
          />
          <Typewriter
            options={{
              strings: [text1, text2, text3]
            }}
          />

But this works:

          <Typewriter
            options={{
              strings: text
            }}
          />

just manage the state of text in React, and pass the currently rendered string directly (not in an array)