@@ -210,11 +210,21 @@ class VTSourceRendererBase extends CustomLayerItemRenderer<IProps & WithTranslat
210210 newState = this . mountRightLabelContainer ( this . props , null , newState , itemElement )
211211 newState = this . mountSourceEndedCountdownContainer ( this . props , newState , itemElement )
212212
213- if ( Object . keys ( newState ) . length > 0 ) {
213+ if ( this . hasStateChanges ( newState ) ) {
214214 this . setState ( newState as IState )
215215 }
216216 }
217217
218+ private hasStateChanges = ( newState : Partial < IState > ) : boolean => {
219+ for ( const [ key , value ] of Object . entries ( newState ) ) {
220+ if ( this . state [ key as keyof IState ] !== value ) {
221+ return true
222+ }
223+ }
224+
225+ return false
226+ }
227+
218228 private updateAnchoredElsWidths = ( ) => {
219229 const leftLabelWidth = this . leftLabel ? getElementWidth ( this . leftLabel ) : 0
220230 const rightLabelWidth = this . rightLabel ? getElementWidth ( this . rightLabel ) : 0
@@ -248,7 +258,7 @@ class VTSourceRendererBase extends CustomLayerItemRenderer<IProps & WithTranslat
248258 newState = this . mountRightLabelContainer ( this . props , prevProps , newState , itemElement )
249259 newState = this . mountSourceEndedCountdownContainer ( this . props , newState , itemElement )
250260
251- if ( Object . keys ( newState ) . length > 0 ) {
261+ if ( this . hasStateChanges ( newState ) ) {
252262 this . setState ( newState as IState , ( ) => {
253263 if ( newState . noticeLevel && newState . noticeLevel !== prevState . noticeLevel ) {
254264 this . updateAnchoredElsWidths ( )
0 commit comments