Skip to content

Commit 51db8e3

Browse files
committed
Add scu to avoid unnecessary rerenders on large pages
1 parent 884c360 commit 51db8e3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

components/PodcastView/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ type Props = {
1717
}
1818

1919
class PodcastView extends React.Component<Props> {
20+
shouldComponentUpdate(nextProps: Props) {
21+
const curr = this.props
22+
if (curr.podcast !== nextProps.podcast) return true
23+
return false
24+
}
25+
2026
render() {
2127
const { podcast, episodes } = this.props
22-
2328
return (
2429
<Grid data-cy="podcast-view">
2530

components/PodcastsGrid/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ type Props = {
99
}
1010

1111
class PodcastsGrid extends React.Component<Props> {
12+
shouldComponentUpdate(nextProps: Props) {
13+
const curr = this.props
14+
if (curr.podcasts !== nextProps.podcasts) return true
15+
return false
16+
}
1217
render() {
1318
const { podcasts } = this.props
14-
1519
return (
1620
<Container>
1721
<Grid>

pages/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class Index extends React.Component<Props> {
2727

2828
render() {
2929
const { podcasts } = this.props
30-
3130
return (
3231
<Page dataCy={'home-view'}>
3332
<Head>

0 commit comments

Comments
 (0)