()
| 10 | ] |
| 11 | |
| 12 | export default function App() { |
| 13 | const [index, set] = React.useState(0) |
| 14 | const transitions = useTransition(index, { |
| 15 | key: index, |
| 16 | from: { opacity: 0 }, |
| 17 | enter: { opacity: 1 }, |
| 18 | leave: { opacity: 0 }, |
| 19 | config: { duration: 3000 }, |
| 20 | onRest: (_a, _b, item) => { |
| 21 | if (index === item) { |
| 22 | set(state => (state + 1) % slides.length) |
| 23 | } |
| 24 | }, |
| 25 | exitBeforeEnter: true, |
| 26 | }) |
| 27 | return ( |
| 28 | <div className="flex fill center"> |
| 29 | {transitions((style, i) => ( |
| 30 | <animated.div |
| 31 | className={styles.bg} |
| 32 | style={{ |
| 33 | ...style, |
| 34 | backgroundImage: `url(https://images.unsplash.com/${slides[i]}?w=1920&q=80&auto=format&fit=crop)`, |
| 35 | }} |
| 36 | /> |
| 37 | ))} |
| 38 | </div> |
| 39 | ) |
| 40 | } |
nothing calls this directly
no test coverage detected