Skip to content

Commit

Permalink
Use shouldComponentUpdate to prevent unnecessary rendering
Browse files Browse the repository at this point in the history
YouTube and Vimeo actually don't ever need re-rendering
SoundCloud only needs to render once it has artwork to display
  • Loading branch information
cookpete committed Aug 27, 2015
1 parent b86c76a commit b7ca5a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export default class SoundCloud extends Base {
state = {
image: null
}
shouldComponentUpdate (nextProps, nextState) {
return this.state.image !== nextState.image
}
getSDK () {
if (window[SDK_GLOBAL]) {
return Promise.resolve(window[SDK_GLOBAL])
Expand Down
3 changes: 3 additions & 0 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default class Vimeo extends Base {
this.iframe = this.refs.iframe.getDOMNode()
super.componentDidMount()
}
shouldComponentUpdate () {
return false
}
play (url) {
if (url) {
let id = url.match(MATCH_URL)[3]
Expand Down
3 changes: 3 additions & 0 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default class YouTube extends Base {
static canPlay (url) {
return MATCH_URL.test(url)
}
shouldComponentUpdate () {
return false
}
getSDK () {
if (window[SDK_GLOBAL]) {
return Promise.resolve(window[SDK_GLOBAL])
Expand Down

0 comments on commit b7ca5a6

Please sign in to comment.