Skip to content

Commit b7ca5a6

Browse files
committed
Use shouldComponentUpdate to prevent unnecessary rendering
YouTube and Vimeo actually don't ever need re-rendering SoundCloud only needs to render once it has artwork to display
1 parent b86c76a commit b7ca5a6

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/players/SoundCloud.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export default class SoundCloud extends Base {
1818
state = {
1919
image: null
2020
}
21+
shouldComponentUpdate (nextProps, nextState) {
22+
return this.state.image !== nextState.image
23+
}
2124
getSDK () {
2225
if (window[SDK_GLOBAL]) {
2326
return Promise.resolve(window[SDK_GLOBAL])

src/players/Vimeo.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default class Vimeo extends Base {
1717
this.iframe = this.refs.iframe.getDOMNode()
1818
super.componentDidMount()
1919
}
20+
shouldComponentUpdate () {
21+
return false
22+
}
2023
play (url) {
2124
if (url) {
2225
let id = url.match(MATCH_URL)[3]

src/players/YouTube.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default class YouTube extends Base {
1414
static canPlay (url) {
1515
return MATCH_URL.test(url)
1616
}
17+
shouldComponentUpdate () {
18+
return false
19+
}
1720
getSDK () {
1821
if (window[SDK_GLOBAL]) {
1922
return Promise.resolve(window[SDK_GLOBAL])

0 commit comments

Comments
 (0)