File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -12,20 +12,25 @@ class Header extends React.Component {
1212 constructor ( props ) {
1313 super ( props ) ;
1414 this . state = { message : null } ;
15+ this . timeout = null ;
1516 }
1617
1718 componentWillReceiveProps ( nextProps ) {
1819 const { newUnminedMessage } = nextProps ;
1920
2021 if ( newUnminedMessage && this . props . newUnminedMessage !== newUnminedMessage ) {
2122 if ( this . state . message ) {
22- setTimeout ( ( ) => this . setState ( { message : nextProps . newUnminedMessage } ) , MSG_DELAY ) ;
23+ this . timeout = setTimeout ( ( ) => this . setState ( { message : nextProps . newUnminedMessage } ) , MSG_DELAY ) ;
2324 } else {
2425 this . setState ( { message : nextProps . newUnminedMessage } ) ;
2526 }
2627 }
2728 }
28-
29+ componentWillUnmount ( ) {
30+ if ( this . timeout ) {
31+ clearTimeout ( this . timeout ) ;
32+ }
33+ }
2934 render ( ) {
3035 const {
3136 getStarted,
You can’t perform that action at this time.
0 commit comments