Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check iframe is lost in development mode #398

Open
sangzn34 opened this issue Jun 26, 2023 · 2 comments
Open

fix: check iframe is lost in development mode #398

sangzn34 opened this issue Jun 26, 2023 · 2 comments

Comments

@sangzn34
Copy link

From Issue #369

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] 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.

@dcsan
Copy link

dcsan commented Apr 9, 2024

@sangzn34 did you publish a fork at all? this seems like a critical fix for many people!

Cannot read properties of null (reading 'src')

@dcsan
Copy link

dcsan commented Apr 9, 2024

update I forked the repo and added this to the TS. But I don't think it fixes the bug, i still see the crash when installing the plugin locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants