WinterCore / react-text-transition

Animate your text changes
MIT License
601 stars 26 forks source link

How to render a space #46

Closed HugoMito closed 2 years ago

HugoMito commented 2 years ago

Hi support team,

Could you guide me on how to render a space?

import ReactTextTransition from "react-text-transition";

{"Please, wait...".split("").map((character, index) => {
  return <ReactTextTransition
    className="loading"
    delay={index * 70}
    direction="up"
    inline
    key={index}
    noOverflow
    text={character} />
})}

The code above displays:

Please,wait...

Thanks for your support!

ch3rn1k commented 2 years ago

Well, this package ignores "empty" variable, so you can do a small trick by wrapping your space character with special symbol Word Joiner:

{"Please, wait...".split("").map((character, index) => {
    return <TextTransition
      className="loading"
      delay={index * 70}
      direction="up"
      inline
      key={index}
      noOverflow
      text={character === ' ' ? '⁠ ⁠' : character} />
  })}
HugoMito commented 2 years ago

Thanks a lot @ch3rn1k! That trick worked perfectly fine.

I am closing this issue. Regards,