@@ -133,14 +133,16 @@ class TweenOne extends Component {
133
133
}
134
134
135
135
componentDidMount ( ) {
136
- this . setDom ( )
136
+ this . dom = ReactDom . findDOMNode ( this ) ;
137
137
if ( this . dom && this . dom . nodeName !== '#text' ) {
138
138
this . start ( ) ;
139
139
}
140
140
}
141
141
142
142
componentDidUpdate ( ) {
143
- this . setDom ( ) ;
143
+ if ( ! this . dom ) {
144
+ this . dom = ReactDom . findDOMNode ( this ) ;
145
+ }
144
146
// 样式更新了后再执行动画;
145
147
if ( this . updateAnim && this . dom && this . dom . nodeName !== '#text' ) {
146
148
if ( this . tween ) {
@@ -190,10 +192,6 @@ class TweenOne extends Component {
190
192
this . startTime = ticker . time ;
191
193
} ;
192
194
193
- setDom = ( ) => {
194
- this . dom = this . dom || ReactDom . findDOMNode ( this ) ;
195
- }
196
-
197
195
restart = ( ) => {
198
196
if ( ! this . tween ) {
199
197
return ;
@@ -338,9 +336,6 @@ class TweenOne extends Component {
338
336
} ) ;
339
337
// component 为空时调用子级的。。
340
338
const { className, children } = props ;
341
- const ref = c => {
342
- this . dom = c ;
343
- } ;
344
339
if ( ! component && typeof children !== 'string' ) {
345
340
if ( ! children ) {
346
341
return children ;
@@ -350,14 +345,9 @@ class TweenOne extends Component {
350
345
// 合并 style 与 className。
351
346
const newStyle = { ...childStyle , ...props . style } ;
352
347
const newClassName = className ? `${ className } ${ childClass } ` : childClass ;
353
- return React . cloneElement ( children , {
354
- style : newStyle ,
355
- ref,
356
- className : newClassName ,
357
- } ) ;
348
+ return React . cloneElement ( children , { style : newStyle , className : newClassName } ) ;
358
349
}
359
350
return React . createElement ( component , {
360
- ref : typeof component === 'string' ? ref : undefined ,
361
351
...props ,
362
352
...componentProps ,
363
353
} ) ;
0 commit comments