Skip to content

fix: check iframe is lost in development mode #398

@sangzn34

Description

@sangzn34

From Issue #369

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-youtube@10.1.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-youtube/dist/YouTube.esm.js b/node_modules/react-youtube/dist/YouTube.esm.js
index ebb1e1f..8120fbb 100644
--- a/node_modules/react-youtube/dist/YouTube.esm.js
+++ b/node_modules/react-youtube/dist/YouTube.esm.js
@@ -186,6 +186,9 @@ var _YouTube = class extends React.Component {
     this.updatePlayer = () => {
       var _a;
       (_a = this.internalPlayer) == null ? void 0 : _a.getIframe().then((iframe) => {
+        if (!iframe) {
+          return
+        }
         if (this.props.id)
           iframe.setAttribute("id", this.props.id);
         else
diff --git a/node_modules/react-youtube/dist/YouTube.js b/node_modules/react-youtube/dist/YouTube.js
index 48ff958..55f6f48 100644
--- a/node_modules/react-youtube/dist/YouTube.js
+++ b/node_modules/react-youtube/dist/YouTube.js
@@ -213,6 +213,9 @@ var _YouTube = class extends import_react.default.Component {
     this.updatePlayer = () => {
       var _a;
       (_a = this.internalPlayer) == null ? void 0 : _a.getIframe().then((iframe) => {
+        if (!iframe) {
+          return
+        }
         if (this.props.id)
           iframe.setAttribute("id", this.props.id);
         else

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions