Skip to content
Discussion options

You must be logged in to vote

When isLoaded is true your message bubbles need to appear, which makes useTransition a better solution here as it handles mount and unmount animations.

const Stuff = () => {
  const [isLoaded, setIsLoaded] = useState(false);

  const data = isLoaded ? [1, 2] : [];

  const transitions = useTransition(data, {
    from: {
      opacity: 0,
      scale: 0.93,
    },
    enter: (msg, i) => ({
      delay: () => {
        return i * 500;
      },
      opacity: 1,
      scale: 1,
    }),
  });

  const msgs = transitions((style, msg) => {
    return (
      <a.div key={msg} style={style} className="message-bubble">
        {msg}
      </a.div>
    );
  });

  return (
    <div>
      <button o…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sanderwapstra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants