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

Function App

demo/src/sandboxes/simple-transition/src/App.tsx:27–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25]
26
27export default function App() {
28 const [index, set] = React.useState(0)
29 const onClick = () => set(state => (state + 1) % 3)
30 const transRef = useSpringRef()
31 const transitions = useTransition(index, {
32 ref: transRef,
33 keys: null,
34 from: { opacity: 0, transform: 'translate3d(100%,0,0)' },
35 enter: { opacity: 1, transform: 'translate3d(0%,0,0)' },
36 leave: { opacity: 0, transform: 'translate3d(-50%,0,0)' },
37 })
38 React.useEffect(() => {
39 transRef.start()
40 }, [index, transRef])
41 return (
42 <div className={`flex fill ${styles.container}`} onClick={onClick}>
43 {transitions((style, i) => {
44 const Page = pages[i]
45 return <Page style={style} />
46 })}
47 </div>
48 )
49}

Callers

nothing calls this directly

Calls 3

useSpringRefFunction · 0.85
useTransitionFunction · 0.85
startMethod · 0.65

Tested by

no test coverage detected