@@ -38,7 +38,7 @@ class ReactTooltip extends Component {
3838 watchWindow : PropTypes . bool ,
3939 isCapture : PropTypes . bool ,
4040 globalEventOff : PropTypes . string ,
41- getContent : PropTypes . func
41+ getContent : PropTypes . any
4242 }
4343
4444 constructor ( props ) {
@@ -64,6 +64,7 @@ class ReactTooltip extends Component {
6464 this . mount = true
6565 this . delayShowLoop = null
6666 this . delayHideLoop = null
67+ this . intervalUpdateContent = null
6768 }
6869
6970 componentDidMount ( ) {
@@ -75,8 +76,7 @@ class ReactTooltip extends Component {
7576 componentWillUnmount ( ) {
7677 this . mount = false
7778
78- clearTimeout ( this . delayShowLoop )
79- clearTimeout ( this . delayHideLoop )
79+ this . clearTimer ( )
8080
8181 this . unbindListener ( )
8282 this . removeScrollListener ( )
@@ -170,11 +170,13 @@ class ReactTooltip extends Component {
170170 const originTooltip = e . currentTarget . getAttribute ( 'data-tip' )
171171 const isMultiline = e . currentTarget . getAttribute ( 'data-multiline' ) || multiline || false
172172
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+ }
178180 }
179181
180182 const placeholder = getTipContent ( originTooltip , content , isMultiline )
@@ -193,6 +195,16 @@ class ReactTooltip extends Component {
193195 } , ( ) => {
194196 this . addScrollListener ( e )
195197 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+ }
196208 } )
197209 }
198210
@@ -228,8 +240,7 @@ class ReactTooltip extends Component {
228240
229241 if ( ! this . mount ) return
230242
231- clearTimeout ( this . delayShowLoop )
232- clearTimeout ( this . delayHideLoop )
243+ this . clearTimer ( )
233244 this . delayHideLoop = setTimeout ( ( ) => {
234245 this . setState ( {
235246 show : false
@@ -282,6 +293,15 @@ class ReactTooltip extends Component {
282293 }
283294 }
284295
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+
285305 render ( ) {
286306 const { placeholder, extraClass, html} = this . state
287307 let tooltipClass = classname (
0 commit comments