@@ -37,7 +37,6 @@ class SLDSNotification extends React.Component {
37
37
constructor ( props ) {
38
38
super ( props ) ;
39
39
this . state = {
40
- isOpen : this . props . isOpen ,
41
40
interval : null ,
42
41
revealForScreenreader : false ,
43
42
} ;
@@ -47,24 +46,25 @@ class SLDSNotification extends React.Component {
47
46
if ( this . props . duration ) {
48
47
const that = this ;
49
48
setTimeout ( function ( ) {
50
- that . setState ( { isOpen : false } ) ;
49
+ this . onDismiss ( ) ;
51
50
} , that . props . duration ) ;
52
51
}
53
52
}
54
53
55
54
componentWillUnmount ( ) {
56
- this . setState ( { interval : null } ) ;
55
+ this . setState ( {
56
+ interval : null
57
+ } ) ;
57
58
}
58
59
59
60
componentWillReceiveProps ( nextProps ) {
60
61
if ( this . props . isOpen !== nextProps . isOpen ) {
61
- this . setState ( { isOpen : nextProps . isOpen } ) ;
62
62
if ( nextProps . isOpen && ! this . state . interval ) {
63
63
this . setState ( { interval : setTimeout ( ( ) => {
64
- this . setState ( { revealForScreenreader : ! this . state . revealForScreenreader } ) ;
65
- console . log ( 'the isOpen state inside is' , this . state . isOpen ) ;
64
+ this . setState ( { revealForScreenreader : true } ) ;
66
65
} , 500 ) } )
67
66
}
67
+ console . log ( 'revealForScreen' , this . state . revealForScreenreader ) ;
68
68
}
69
69
}
70
70
@@ -104,7 +104,10 @@ class SLDSNotification extends React.Component {
104
104
105
105
onDismiss ( ) {
106
106
if ( this . props . onDismiss ) this . props . onDismiss ( ) ;
107
- this . setState ( { isOpen : false } ) ;
107
+ this . setState ( {
108
+ revealForScreenreader : false ,
109
+ interval : null ,
110
+ } ) ;
108
111
}
109
112
110
113
renderAlertContent ( ) {
@@ -161,7 +164,7 @@ class SLDSNotification extends React.Component {
161
164
}
162
165
163
166
render ( ) {
164
- if ( this . state . isOpen ) {
167
+ if ( this . props . isOpen ) {
165
168
return (
166
169
< div className = "slds-notify-container" >
167
170
< div ref = "alertContent" className = { this . getClassName ( ) } role = "alert" >
0 commit comments