Skip to content

Commit 979e639

Browse files
committed
Prevent errors when unmounting before SDK loads
1 parent d3401dc commit 979e639

6 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/players/DailyMotion.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default class DailyMotion extends Component {
2828
return
2929
}
3030
getSDK(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, DM => DM.player).then(DM => {
31+
if (!this.container) return
3132
const Player = DM.player
3233
this.player = new Player(this.container, {
3334
width: '100%',

src/players/SoundCloud.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default class SoundCloud extends Component {
1717
fractionLoaded = null
1818
load (url, isReady) {
1919
getSDK(SDK_URL, SDK_GLOBAL).then(SC => {
20+
if (!this.iframe) return
2021
const { PLAY, PLAY_PROGRESS, PAUSE, FINISH, ERROR } = SC.Widget.Events
2122
if (!isReady) {
2223
this.player = SC.Widget(this.iframe)

src/players/Streamable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class Streamable extends Component {
1616
secondsLoaded = null
1717
load (url) {
1818
getSDK(SDK_URL, SDK_GLOBAL).then(playerjs => {
19+
if (!this.iframe) return
1920
this.player = new playerjs.Player(this.iframe)
2021
this.player.on('ready', this.props.onReady)
2122
this.player.on('play', this.props.onPlay)

src/players/Vidme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default class Vidme extends FilePlayer {
4141
const { onError } = this.props
4242
this.stop()
4343
this.getData(url).then(data => {
44+
if (!this.player) return
4445
this.player.src = this.getURL(data)
4546
}, onError)
4647
}

src/players/Vimeo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class Vimeo extends Component {
2222
return
2323
}
2424
getSDK(SDK_URL, SDK_GLOBAL).then(Vimeo => {
25+
if (!this.container) return
2526
this.player = new Vimeo.Player(this.container, {
2627
...this.props.config.vimeo.playerOptions,
2728
url,

src/players/YouTube.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class YouTube extends Component {
2424
return
2525
}
2626
getSDK(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, YT => YT.loaded).then(YT => {
27+
if (!this.container) return
2728
this.player = new YT.Player(this.container, {
2829
width: '100%',
2930
height: '100%',

0 commit comments

Comments
 (0)