@@ -56,56 +56,70 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
56
56
motionAppear,
57
57
} ,
58
58
ref ,
59
- ) => (
60
- < CSSMotion
61
- visible = { visible }
62
- ref = { ref }
63
- motionName = "motion"
64
- motionAppear = { motionAppear }
65
- onAppearStart = { getCollapsedHeight }
66
- onAppearActive = { getMaxHeight }
67
- onAppearEnd = { onAppear }
68
- onLeaveStart = { getCurrentHeight }
69
- onLeaveActive = { getCollapsedHeight }
70
- onLeaveEnd = { ( ) => {
71
- onLeave ( id ) ;
72
- } }
73
- >
74
- { ( { className, style } , motionRef ) => {
75
- return (
76
- < div ref = { motionRef } className = { classNames ( 'item' , className ) } style = { style } data-id = { id } >
77
- < div style = { { height : itemUuid % 2 ? 100 : undefined } } >
78
- < button
79
- type = "button"
80
- onClick = { ( ) => {
81
- onClose ( id ) ;
82
- } }
83
- >
84
- Close
85
- </ button >
86
- < button
87
- type = "button"
88
- onClick = { ( ) => {
89
- onInsertBefore ( id ) ;
90
- } }
91
- >
92
- Insert Before
93
- </ button >
94
- < button
95
- type = "button"
96
- onClick = { ( ) => {
97
- onInsertAfter ( id ) ;
98
- } }
99
- >
100
- Insert After
101
- </ button >
102
- { id }
59
+ ) => {
60
+ const motionRef = React . useRef ( false ) ;
61
+ React . useEffect ( ( ) => {
62
+ return ( ) => {
63
+ if ( motionRef . current ) {
64
+ onAppear ( ) ;
65
+ }
66
+ } ;
67
+ } , [ ] ) ;
68
+
69
+ return (
70
+ < CSSMotion
71
+ visible = { visible }
72
+ ref = { ref }
73
+ motionName = "motion"
74
+ motionAppear = { motionAppear }
75
+ onAppearStart = { getCollapsedHeight }
76
+ onAppearActive = { node => {
77
+ motionRef . current = true ;
78
+ return getMaxHeight ( node ) ;
79
+ } }
80
+ onAppearEnd = { onAppear }
81
+ onLeaveStart = { getCurrentHeight }
82
+ onLeaveActive = { getCollapsedHeight }
83
+ onLeaveEnd = { ( ) => {
84
+ onLeave ( id ) ;
85
+ } }
86
+ >
87
+ { ( { className, style } , motionRef ) => {
88
+ return (
89
+ < div ref = { motionRef } className = { classNames ( 'item' , className ) } style = { style } data-id = { id } >
90
+ < div style = { { height : itemUuid % 2 ? 100 : undefined } } >
91
+ < button
92
+ type = "button"
93
+ onClick = { ( ) => {
94
+ onClose ( id ) ;
95
+ } }
96
+ >
97
+ Close
98
+ </ button >
99
+ < button
100
+ type = "button"
101
+ onClick = { ( ) => {
102
+ onInsertBefore ( id ) ;
103
+ } }
104
+ >
105
+ Insert Before
106
+ </ button >
107
+ < button
108
+ type = "button"
109
+ onClick = { ( ) => {
110
+ onInsertAfter ( id ) ;
111
+ } }
112
+ >
113
+ Insert After
114
+ </ button >
115
+ { id }
116
+ </ div >
103
117
</ div >
104
- </ div >
105
- ) ;
106
- } }
107
- </ CSSMotion >
108
- ) ;
118
+ ) ;
119
+ } }
120
+ </ CSSMotion >
121
+ ) ;
122
+ } ;
109
123
110
124
const ForwardMyItem = React . forwardRef ( MyItem ) ;
111
125
@@ -165,13 +179,13 @@ const Demo = () => {
165
179
height = { 200 }
166
180
itemHeight = { 20 }
167
181
itemKey = "id"
168
- disabled = { animating }
182
+ // disabled={animating}
169
183
ref = { listRef }
170
184
style = { {
171
185
border : '1px solid red' ,
172
186
boxSizing : 'border-box' ,
173
187
} }
174
- onSkipRender = { onAppear }
188
+ // onSkipRender={onAppear}
175
189
// onItemRemove={onAppear}
176
190
>
177
191
{ ( item , index ) => (
0 commit comments