Skip to content

Commit 6cda8b5

Browse files
committed
chore: convert some examples to new useTransition signature
1 parent d99f73f commit 6cda8b5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

demos/hooks/masonry-grid/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default function App() {
3030
: []
3131

3232
const trail = FAST_MODE ? 25 : 80
33-
const transitions = useTransition(gridItems, item => item.css, {
33+
const transition = useTransition(gridItems, {
34+
key: item => item.css,
3435
from: ({ xy, width, height }) => ({
3536
xy,
3637
width,
@@ -55,9 +56,8 @@ export default function App() {
5556
set(items.length ? [] : data)
5657
}}>
5758
<div {...bind} className="mgrid-list">
58-
{transitions.map(({ item, props: { xy, scale, ...rest }, key }) => (
59+
{transition(({ xy, scale, ...rest }, item) => (
5960
<a.div
60-
key={key}
6161
style={{
6262
transform: to(
6363
[xy, scale],

demos/hooks/notification-hub/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function MessageHub({
1717
const [cancelMap] = useState(() => new WeakMap())
1818
const [items, setItems] = useState([])
1919

20-
const transitions = useTransition(items, item => item.key, {
20+
const transition = useTransition(items, {
21+
key: item => item.key,
2122
from: { opacity: 0, height: 0, life: '100%' },
2223
enter: item => async (next, stop) => {
2324
if (DEBUG) console.log(` Entering:`, item.key)
@@ -49,8 +50,8 @@ function MessageHub({
4950

5051
return (
5152
<Container>
52-
{transitions.map(({ key, item, props: { life, ...style } }) => (
53-
<Message key={key} style={style}>
53+
{transition(({ life, ...style }, item) => (
54+
<Message style={style}>
5455
<Content ref={ref => ref && refMap.set(item, ref)}>
5556
<Life style={{ right: life }} />
5657
<p>{item.msg}</p>

demos/hooks/simple-transition/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function App() {
2626
() => set(state => (state === 2 ? 0 : state + 1)),
2727
[]
2828
)
29-
const transitions = useTransition(index, null, {
29+
const transition = useTransition(index, {
3030
from: { opacity: 0, transform: 'translate3d(100%,0,0)' },
3131
initial: { opacity: 1, transform: 'translate3d(0%,0,0)' },
3232
enter: { opacity: 1, transform: 'translate3d(0%,0,0)' },
@@ -37,9 +37,9 @@ export default function App() {
3737

3838
return (
3939
<div className="simple-trans-main" onClick={onClick}>
40-
{transitions.map(({ item, props, key }) => {
40+
{transition((props, item) => {
4141
const Page = pages[item]
42-
return <Page key={key} style={props} />
42+
return <Page style={props} />
4343
})}
4444
</div>
4545
)

0 commit comments

Comments
 (0)