MCPcopy
hub / github.com/pmndrs/react-spring / App

Function App

demo/src/sandboxes/image-fade/src/App.tsx:12–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10]
11
12export 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}

Callers

nothing calls this directly

Calls 2

useTransitionFunction · 0.85
setFunction · 0.85

Tested by

no test coverage detected