-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ReactPlayer not working in React 17 and Next 10 #1165
Comments
I forked your repo and extend the window check with a second check, if you are using
|
@cookpete well, webpack polyfills the global variable, therefore it is not available in the bundled version when I install the player as dep. The same issues re-occur. I have now a patched version without the React.Suspense and React.lazy logic and only bundle the FilePlayer, as I only need this at the moment. Maybe we can find a solution together to have your version working for Next and SSR in favour of my fork 😃 |
@fmacherey Can you post some steps on how to reproduce this? I just cloned |
@cookpete He mentioned SSR (Server Side Rendering). SSR is not by default, you would need to call it on a page where you embed react-player. https://nextjs.org/docs/basic-features/pages#server-side-rendering |
@TheManFromEarth1 SSR seemed to be active in the standard @fmacherey Are you using |
@cookpete no i'm not using this package. I noticed the bug while upgrading from next 9 to 10 and react 16 to 17. Maybe there was some mess up with versions. |
@cookpete Hello 😄 I might have the same issue with gatsby when updating react and react-dom from ^16.3.1 to ^17.0.1. On react & react-dom 17.0.1 I have the exact same error as described above. Works like a charm on 16.13.1. |
I had the same issue when importing the whole react-player bundle. Since I only use vimeo, I tried importing ReactPlayer from react-player/vimeo. This fixed my problem. react-player 2.9 |
Same issue on NextJS (^11.0.1) - breaks if importing main or /lazy |
Same issue on Gatsby 3.11.1 |
PSA: In case anyone comes across this... Double checking that react and react-dom are ^17.0.2 solved this for me. I was facing the issues above - importing main or lazy wasn't working. |
Current Behavior
ReactPlayer is not working with NextJS. I use ReactPlayer to show videos in several formats like mp4 and hls.
At the moment, I am upgrading my dependencies from prior versions to current stable. After updating versions, I get an exception from the console and the page crashes.
Versions:
I use the current version of react-player@2.8.2. The error message in the browser console:
It looks like the problem comes from the React.Suspense Component, so, I switched to next/dynamic import, with no success:
Also there is no change if omit the global.window check or the lazy-Package.
Expected Behavior
ReactPlayer should only load client side in NextJS App.
Environment
The text was updated successfully, but these errors were encountered: