Skip to content

Commit

Permalink
Clean up shouldComponentUpdate logic
Browse files Browse the repository at this point in the history
* All players now need to update when url changes
  • Loading branch information
albanqoku committed Dec 24, 2015
1 parent 4ef3d47 commit 3039df9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/players/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default class Base extends Component {
this.setVolume(nextProps.volume)
}
}
shouldComponentUpdate (nextProps) {
return this.props.url !== nextProps.url
}
update = () => {
let progress = {}
const loaded = this.getFractionLoaded()
Expand Down
3 changes: 0 additions & 3 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export default class FilePlayer extends Base {
this.player.onerror = this.props.onError
super.componentDidMount()
}
shouldComponentUpdate (nextProps) {
return this.props.url !== nextProps
}
play (url) {
this.player.play()
}
Expand Down
5 changes: 4 additions & 1 deletion src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default class SoundCloud extends Base {
image: null
}
shouldComponentUpdate (nextProps, nextState) {
return this.state.image !== nextState.image
return (
super.shouldComponentUpdate(nextProps, nextState) ||
this.state.image !== nextState.image
)
}
getSDK () {
if (window[SDK_GLOBAL]) {
Expand Down
3 changes: 0 additions & 3 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export default class Vimeo extends Base {
this.iframe = this.refs.iframe
super.componentDidMount()
}
shouldComponentUpdate () {
return false
}
play (url) {
if (url) {
const id = url.match(MATCH_URL)[3]
Expand Down
3 changes: 0 additions & 3 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ 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 3039df9

Please sign in to comment.