@@ -38,7 +38,7 @@ class ReactTooltip extends Component {
38
38
watchWindow : PropTypes . bool ,
39
39
isCapture : PropTypes . bool ,
40
40
globalEventOff : PropTypes . string ,
41
- getContent : PropTypes . func
41
+ getContent : PropTypes . any
42
42
}
43
43
44
44
constructor ( props ) {
@@ -64,6 +64,7 @@ class ReactTooltip extends Component {
64
64
this . mount = true
65
65
this . delayShowLoop = null
66
66
this . delayHideLoop = null
67
+ this . intervalUpdateContent = null
67
68
}
68
69
69
70
componentDidMount ( ) {
@@ -75,8 +76,7 @@ class ReactTooltip extends Component {
75
76
componentWillUnmount ( ) {
76
77
this . mount = false
77
78
78
- clearTimeout ( this . delayShowLoop )
79
- clearTimeout ( this . delayHideLoop )
79
+ this . clearTimer ( )
80
80
81
81
this . unbindListener ( )
82
82
this . removeScrollListener ( )
@@ -170,11 +170,13 @@ class ReactTooltip extends Component {
170
170
const originTooltip = e . currentTarget . getAttribute ( 'data-tip' )
171
171
const isMultiline = e . currentTarget . getAttribute ( 'data-multiline' ) || multiline || false
172
172
173
- let content
174
- if ( children ) {
175
- content = children
176
- } else if ( getContent ) {
177
- content = getContent ( )
173
+ let content = children
174
+ if ( getContent ) {
175
+ if ( Array . isArray ( getContent ) ) {
176
+ content = getContent [ 0 ] && getContent [ 0 ] ( )
177
+ } else {
178
+ content = getContent ( )
179
+ }
178
180
}
179
181
180
182
const placeholder = getTipContent ( originTooltip , content , isMultiline )
@@ -193,6 +195,16 @@ class ReactTooltip extends Component {
193
195
} , ( ) => {
194
196
this . addScrollListener ( e )
195
197
this . updateTooltip ( e )
198
+
199
+ if ( getContent && Array . isArray ( getContent ) ) {
200
+ this . intervalUpdateContent = setInterval ( ( ) => {
201
+ const { getContent} = this . props
202
+ const placeholder = getTipContent ( originTooltip , getContent [ 0 ] ( ) , isMultiline )
203
+ this . setState ( {
204
+ placeholder
205
+ } )
206
+ } , getContent [ 1 ] )
207
+ }
196
208
} )
197
209
}
198
210
@@ -228,8 +240,7 @@ class ReactTooltip extends Component {
228
240
229
241
if ( ! this . mount ) return
230
242
231
- clearTimeout ( this . delayShowLoop )
232
- clearTimeout ( this . delayHideLoop )
243
+ this . clearTimer ( )
233
244
this . delayHideLoop = setTimeout ( ( ) => {
234
245
this . setState ( {
235
246
show : false
@@ -282,6 +293,15 @@ class ReactTooltip extends Component {
282
293
}
283
294
}
284
295
296
+ /**
297
+ * CLear all kinds of timeout of interval
298
+ */
299
+ clearTimer ( ) {
300
+ clearTimeout ( this . delayShowLoop )
301
+ clearTimeout ( this . delayHideLoop )
302
+ clearInterval ( this . intervalUpdateContent )
303
+ }
304
+
285
305
render ( ) {
286
306
const { placeholder, extraClass, html} = this . state
287
307
let tooltipClass = classname (
0 commit comments