1

I'm using these styles with react spring, and after it runs one time, it won't run anymore, if I remove the delay it works fine, why is that?

const styles = useSpring({
  loop: true,
  to: [
    { opacity: 0, color: '#53317e' },
    { opacity: 1, color: 'white' },
  ],
  from: { opacity: 1, color: 'white' },
  delay: 1000,
})
Software Engineer
  • 15,457
  • 7
  • 74
  • 102
Alexander
  • 1,288
  • 5
  • 19
  • 38

1 Answers1

1

lot of time gone but I had same issue.

To fix it, instead of using

const styles = useSpring({ 
   loop: true,
   delay: 2000,
   from: {...},
   to: [{...}, {...}, ...]
 });

I used syntax with passing function instead of object

  const [styles, api] = useSpring(() => ({ ... }) )

And then delay prop stops disabling my loop