react-player icon indicating copy to clipboard operation
react-player copied to clipboard

`ReactPlayer` not working in React 17

Open ijemmao opened this issue 3 years ago • 5 comments

Current Behavior

When using the out-of-the-box ReactPlayer and provided any url, in this case it's a YouTube link, the React Player component fails to render and throws this error in the console.

Uncaught undefined
The above error occurred in one of your React components:
    in Unknown (created by Player)
    in Player (created by ReactPlayer)
    in Suspense (created by ReactPlayer)
    in div (created by ReactPlayer)
    in ReactPlayer

Screen Shot 2022-03-22 at 7 42 47 AM

Expected Behavior

The embedded YouTube video should be present on-screen.

Steps to Reproduce

  1. `import ReactPlayer from 'react-player'
  2. Render the component like <ReactPlayer url={url} /> where url is any link
  3. View the thrown error in the console

Current packages

...
"react-player": "2.10.0",
"react": "17.0.2",
"react-dom": "17.0.2",
...

Other Information

I've seen similar issues in the past closed, but they don't seem to address my case since i'm not using @hot-loader/react-dom or NextJS:

  • https://github.com/cookpete/react-player/issues/1176
  • https://github.com/cookpete/react-player/issues/1165

ijemmao avatar Mar 22 '22 11:03 ijemmao

Aw, since I updated react-dom to ^17.0.2 it works for me.

spereira2017 avatar Mar 23 '22 15:03 spereira2017

Interesting, I've cleared my node_modules cache and reinstalled them and I'm still getting the same bug. Any recommendations for debugging this?

ijemmao avatar Mar 24 '22 13:03 ijemmao

I imported like this: import ReactPlayer from 'react-player/lazy';

spereira2017 avatar Mar 24 '22 14:03 spereira2017

Is anyone able to provide an example repo where this happens? I can spin up a fresh create-react-app and do not get this error on any 17.0.* version of react.

cookpete avatar Mar 25 '22 20:03 cookpete

@cookpete Unfortunately, the repo where I'm experiencing these issues is private. I manage all my packages since I'm not using a solution like create-react-app. Would you know of other possible packages that could interfere with react-player to cause this issue?

@spereira2017 I can try to see if that works!

ijemmao avatar Mar 27 '22 00:03 ijemmao