File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-rotating-text" ,
3
- "version" : " 1.1.0 " ,
3
+ "version" : " 1.1.1 " ,
4
4
"description" : " A simple react component to display an array of words/sentences with a typewriter effect." ,
5
5
"main" : " lib/ReactRotatingText.js" ,
6
6
"author" : " Adrian Li" ,
Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ class ReactRotatingText extends React.Component {
23
23
// save the timeouts so we can stop on unmount
24
24
const timeout = setTimeout ( loopingFunc , pause ) ;
25
25
this . timeouts . push ( timeout ) ;
26
+
27
+ // prevent memory leak
28
+ const maxTimeouts = 100 ;
29
+ if ( this . timeouts . length > maxTimeouts ) {
30
+ clearTimeout ( this . timeouts [ 0 ] ) ;
31
+ this . timeouts . shift ( ) ;
32
+ }
26
33
}
27
34
28
35
_type ( text , callback ) {
@@ -72,7 +79,7 @@ class ReactRotatingText extends React.Component {
72
79
} ;
73
80
74
81
type . bind ( this ) ( items [ index ] , ( ) => {
75
- this . _loop ( erase . bind ( this , nextWord ) , pause ) ;
82
+ this . _loop ( erase . bind ( this , nextWord ) , pause ) ;
76
83
} ) ;
77
84
} ;
78
85
You can’t perform that action at this time.
0 commit comments