Skip to content

Commit 35886cb

Browse files
gnpricechrisbobbe
authored andcommitted
react [nfc]: Use PureComponent where we say we do
In docs/architecture/react.md we say we derive all our class components from React.PureComponent, with one exception, namely MessageList. From a grep, there are a handful of other components where we use simply React.Component instead. I'm not sure the difference has much practical effect on those components, but adjust them to follow our pattern for consistency. None of these components need special behavior in this respect: they don't implement shouldComponentUpdate, and just like for other components in our app the values we pass for their props are never mutated, only replaced with new values.
1 parent df0013c commit 35886cb

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/RootErrorBoundary.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type State = $ReadOnly<{|
3434
*
3535
* [1] https://reactjs.org/docs/error-boundaries.html#how-about-event-handlers
3636
*/
37-
export default class ErrorBoundary extends React.Component<Props, State> {
37+
export default class ErrorBoundary extends React.PureComponent<Props, State> {
3838
static getDerivedStateFromError(error: Error): State {
3939
return { error };
4040
}

src/sharing/ShareToPm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type State = $ReadOnly<{|
3737
choosingRecipients: boolean,
3838
|}>;
3939

40-
export default class ShareToPm extends React.Component<Props, State> {
40+
export default class ShareToPm extends React.PureComponent<Props, State> {
4141
state: State = {
4242
selectedRecipients: [],
4343
choosingRecipients: false,

src/sharing/ShareToStream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type State = $ReadOnly<{|
4747
isTopicFocused: boolean,
4848
|}>;
4949

50-
class ShareToStreamInner extends React.Component<Props, State> {
50+
class ShareToStreamInner extends React.PureComponent<Props, State> {
5151
state = {
5252
streamName: '',
5353
streamId: null,

src/sharing/ShareWrapper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type State = $ReadOnly<{|
9898
* Wraps Around different sharing screens,
9999
* for minimal duplication of code.
100100
*/
101-
class ShareWrapperInner extends React.Component<Props, State> {
101+
class ShareWrapperInner extends React.PureComponent<Props, State> {
102102
static contextType = TranslationContext;
103103
context: GetText;
104104

0 commit comments

Comments
 (0)