File tree 6 files changed +10
-138
lines changed
6 files changed +10
-138
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
2
import style from './index.module.css' ;
4
3
5
4
class TimeBox extends React . Component {
6
5
7
6
shouldComponentUpdate ( nextProps ) {
8
- if ( nextProps . currentTime !== this . props . currentTime ) {
9
- return true ;
10
- }
11
- if ( nextProps . duration !== this . props . duration ) {
7
+ if ( nextProps !== this . props ) {
12
8
return true ;
13
9
}
14
10
15
11
return false ;
16
12
}
13
+
17
14
// as separate function above render for performance
18
15
handleClick = ( e ) => {
19
16
this . props . promptSetCurrentTime ( e ) ;
Original file line number Diff line number Diff line change @@ -21,25 +21,8 @@ import TimeBox from './TimeBox.js';
21
21
22
22
class PlayerControls extends React . Component {
23
23
24
- shouldComponentUpdate ( nextProps ) {
25
- if ( nextProps . currentTime !== this . props . currentTime ) {
26
- return true ;
27
- }
28
- if ( nextProps . duration !== this . props . duration ) {
29
- return true ;
30
- }
31
-
32
- if ( nextProps . playbackRate !== this . props . playbackRate ) {
33
- return true ;
34
- }
35
-
36
- if ( nextProps . isPlaying !== this . props . isPlaying ) {
37
- return true ;
38
- }
39
-
40
- if ( nextProps . isMute !== this . props . isMute ) {
41
- return true ;
42
- }
24
+ shouldComponentUpdate = ( nextProps ) => {
25
+ if ( nextProps !== this . props ) return true ;
43
26
44
27
return false ;
45
28
}
Original file line number Diff line number Diff line change @@ -7,15 +7,7 @@ class ProgressBar extends React.Component {
7
7
8
8
// performance optimization
9
9
shouldComponentUpdate = ( nextProps ) => {
10
- if ( nextProps . buttonClick !== this . props . buttonClick ) {
11
- return true ;
12
- }
13
-
14
- if ( nextProps . value !== this . props . value ) {
15
- return true ;
16
- }
17
-
18
- if ( nextProps . max !== this . props . max ) {
10
+ if ( nextProps !== this . props ) {
19
11
return true ;
20
12
}
21
13
Original file line number Diff line number Diff line change @@ -37,46 +37,9 @@ class TimedTextEditor extends React.Component {
37
37
}
38
38
39
39
shouldComponentUpdate = ( nextProps , nextState ) => {
40
- if ( nextProps . transcriptData !== this . props . transcriptData ) {
41
- return true ;
42
- }
43
-
44
- if ( nextProps . isEditable !== this . props . isEditable ) {
45
- return true ;
46
- }
47
-
48
- if ( nextProps . timecodeOffset !== this . props . timecodeOffset ) {
49
- return true ;
50
- }
51
-
52
- if ( nextProps . showSpeakers !== this . props . showSpeakers ) {
53
- return true ;
54
- }
55
-
56
- if ( nextProps . showTimecodes !== this . props . showTimecodes ) {
57
- return true ;
58
- }
40
+ if ( nextProps !== this . props ) return true ;
59
41
60
- if ( nextProps . fileName !== this . props . fileName ) {
61
- return true ;
62
- }
63
-
64
- // updating TimedTextEditor on every currentTime causes re-renders
65
- if ( nextProps . currentTime !== this . props . currentTime ) {
66
- return true ;
67
- }
68
-
69
- if ( nextState . editorState !== this . state . editorState ) {
70
- return true ;
71
- }
72
-
73
- if ( nextProps . spellCheck !== this . props . spellCheck ) {
74
- return true ;
75
- }
76
-
77
- if ( nextProps . isPauseWhileTypingOn !== this . props . isPauseWhileTypingOn ) {
78
- return true ;
79
- }
42
+ if ( nextState !== this . state ) return true ;
80
43
81
44
return false ;
82
45
}
Original file line number Diff line number Diff line change @@ -65,63 +65,9 @@ class TranscriptEditor extends React.Component {
65
65
66
66
// performance optimization
67
67
shouldComponentUpdate = ( nextProps , nextState ) => {
68
+ if ( nextProps . mediaUrl !== this . props . mediaUrl ) return true ;
68
69
69
- if ( nextState . transcriptData !== this . state . transcriptData ) {
70
- return true ;
71
- }
72
-
73
- if ( nextProps . mediaUrl !== this . props . mediaUrl ) {
74
- return true ;
75
- }
76
-
77
- if ( nextState . currentTime !== this . state . currentTime ) {
78
- return true ;
79
- }
80
-
81
- if ( nextState . isScrollIntoViewOn !== this . state . isScrollIntoViewOn ) {
82
- return true ;
83
- }
84
-
85
- if ( nextState . showSettings !== this . state . showSettings ) {
86
- return true ;
87
- }
88
-
89
- if ( nextState . showShortcuts !== this . state . showShortcuts ) {
90
- return true ;
91
- }
92
- if ( nextState . showExportOptions !== this . state . showExportOptions ) {
93
- return true ;
94
- }
95
-
96
- if ( nextState . isPauseWhileTypingOn !== this . state . isPauseWhileTypingOn ) {
97
- return true ;
98
- }
99
-
100
- if ( nextState . rollBackValueInSeconds !== this . state . rollBackValueInSeconds ) {
101
- return true ;
102
- }
103
-
104
- if ( nextState . timecodeOffset !== this . state . timecodeOffset ) {
105
- return true ;
106
- }
107
-
108
- if ( nextState . showTimecodes !== this . state . showTimecodes ) {
109
- return true ;
110
- }
111
-
112
- if ( nextState . showSpeakers !== this . state . showSpeakers ) {
113
- return true ;
114
- }
115
-
116
- if ( nextState . previewIsDisplayed !== this . state . previewIsDisplayed ) {
117
- return true ;
118
- }
119
-
120
- if ( nextState . mediaDuration !== this . state . mediaDuration ) {
121
- return true ;
122
- }
123
-
124
- return false ;
70
+ return nextState !== this . state ;
125
71
}
126
72
127
73
componentDidUpdate ( prevProps , prevState ) {
Original file line number Diff line number Diff line change @@ -12,16 +12,7 @@ class Header extends React.Component {
12
12
13
13
// to avoid unnecessary re-renders
14
14
shouldComponentUpdate ( nextProps ) {
15
- if ( nextProps . showSettings !== this . props . showSettings ) {
16
- return true ;
17
- }
18
- if ( nextProps . showShortcuts !== this . props . showShortcuts ) {
19
- return true ;
20
- }
21
-
22
- if ( nextProps . mediaControls !== this . props . mediaControls ) {
23
- return true ;
24
- }
15
+ if ( nextProps !== this . props ) return true ;
25
16
26
17
return false ;
27
18
}
You can’t perform that action at this time.
0 commit comments