react-simple-typewriter icon indicating copy to clipboard operation
react-simple-typewriter copied to clipboard

How to randomize words order?

Open GitMalmoer opened this issue 1 year ago • 0 comments

I have the array of facts and every time the typing is done i want new fact, how to achieve that?

  const pickRandomString = () => {
    let random = Math.floor(Math.random() * facts.length);
    console.log(facts[random])
    return [facts[random]];
  }

  const [text, flags] = useTypewriter({
    words: pickRandomString(),
    loop: false,
    typeSpeed: 50,
    deleteSpeed: 40,
    //onLoopDone: () => console.log("done from typewriter hook")
  });

GitMalmoer avatar Apr 19 '23 14:04 GitMalmoer