32

Use react hooks for typing effect easily

 5 years ago
source link: https://www.tuicool.com/articles/hit/ZVNZbqz
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

react-typewriter-hook

⌨️ Use react hooks for typing effect easily

iu2Y7rZ.gif

Install

npm i react-typewriter-hook --save

Example

View example at codesandbox

Usage

// useTypewriter will do these things
// Once Word changed, typewritter will automatically erase last word
// Then type down new word
import useTypewriter from "react-typewriter-hook"

function MagicWritter(word) {
  const typing = useTypewriter(word)
  return typing
}

What happens after call useTypewriter hook

  • Typewriter accept the word, ready to write
  • Typewriter write down your word and waiting for the word change
  • Typewriter once accept the new word, it erases the last word, and write down next

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK