@@ -30,12 +30,17 @@ const propTypes = {
30
30
31
31
const defaultProps = {
32
32
dismissible : true ,
33
+ isOpen : false
33
34
} ;
34
35
35
36
class SLDSNotification extends React . Component {
36
37
constructor ( props ) {
37
38
super ( props ) ;
38
- this . state = { isOpen : this . props . isOpen } ;
39
+ this . state = {
40
+ isOpen : this . props . isOpen ,
41
+ interval : null ,
42
+ addSpace : false ,
43
+ } ;
39
44
}
40
45
41
46
componentDidMount ( ) {
@@ -47,9 +52,18 @@ class SLDSNotification extends React.Component {
47
52
}
48
53
}
49
54
55
+ componentWillUnmount ( ) {
56
+ this . setState ( { interval : null } ) ;
57
+ }
58
+
50
59
componentWillReceiveProps ( nextProps ) {
51
60
if ( this . props . isOpen !== nextProps . isOpen ) {
52
61
this . setState ( { isOpen : nextProps . isOpen } ) ;
62
+ if ( nextProps . isOpen && ! this . state . interval ) {
63
+ this . setState ( { interval : setTimeout ( ( ) => {
64
+ this . setState ( { addSpace : ! this . state . addSpace } ) ;
65
+ } , 1000 ) } )
66
+ }
53
67
}
54
68
}
55
69
@@ -124,15 +138,24 @@ class SLDSNotification extends React.Component {
124
138
} ) ;
125
139
}
126
140
141
+ renderContent ( ) {
142
+ return (
143
+ < div >
144
+ { this . state . addSpace ? " x" : "" }
145
+ < p ref = "test" className = "slds-assistive-text" > { this . props . theme } </ p >
146
+ { this . renderClose ( ) }
147
+ { this . renderAlertContent ( ) }
148
+ { this . renderToastContent ( ) }
149
+ </ div >
150
+ )
151
+ }
152
+
127
153
render ( ) {
128
154
if ( this . state . isOpen ) {
129
155
return (
130
156
< div className = "slds-notify-container" >
131
- < div className = { this . getClassName ( ) } role = "alert" >
132
- < span className = "slds-assistive-text" > { this . props . theme } </ span >
133
- { this . renderClose ( ) }
134
- { this . renderAlertContent ( ) }
135
- { this . renderToastContent ( ) }
157
+ < div ref = "alertContent" className = { this . getClassName ( ) } role = "alert" >
158
+ { this . renderContent ( ) }
136
159
</ div >
137
160
</ div >
138
161
) ;
0 commit comments