-
Notifications
You must be signed in to change notification settings - Fork 55
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
NextJs integration support #873
Comments
can create codesandbox demo for us? |
You can't because the issue only appears during yarn dev - not after it's built so codesandbox won't be able to replicate the issue but it's easy as starting a new nextjs project and export default function IndexPage() {
return (
<div>
<Plyr
source={{
type: "video",
sources: [{ src: "9bZkp7q19f0", provider: "youtube" }]
}}
/>
</div>
);
} |
Hey @haluvibe , the only non-serverside action I'm suspicious of it is about this line: Line 38 in f5d6ab7
But the error and our last investigation show that the problem was related to the plyr itself. Any try-out or suggestions for fixing this issue is pleased |
no idea, I can't have multiple videos with this library unfortunately atm |
@chintan9 the same issue I am facing in my project, can anyone give a solution, please... |
Same issue here. |
No news? |
Hey all |
Thanks a lot @realamirhe - it's a major issue causing errors on every page load, multiple apps, etc. and makes Plyr React super difficult to use. |
https://bobbyhadz.com/blog/javascript-cannot-read-property-getattribute-of-null It look like there some issue how we use nextjs with library.
@erip2 can you share deployed project? |
Whoever wrote that blog post using GPT to sell their book at the end… amateur 🤣
|
At least SEO was good. I will look much deeper on this issue. @altechzilla It very helpful if you create sample repo for this issue. Please use latest stable version without material UI. |
Thanks @realamirhe |
damn ... we planned to use Plyr for 3 upcoming NextJs projects ... hopefully it can be fixed... strange is also that the error is thrown randomly - but in every NextJs project we tested it - solution for now is that we use another player. Is it fixable in general or is Plyr just not compatible with the way NextJs works behind the scenes? |
please consider keeping sampotts/plyr#2599 active till it gets its desired attraction. I also tested mocking the media object in the plyr instance in the rendering, but it happens in the initiation phase, it might be possible to make another could someone test the error occurrence with the patched plyr package (patch-package) and see error still exists, if that resolves the issue we might open a pull request for solving it ourselves? |
Im having the same issue |
@MokDevelopment whats the alternative player you tried? |
I Provided an id before the source attribute and it worked
|
I'm having the same issue (I think). Player appears for a moment and then disappears. I am trying to render an array of video players. The error that Next JS throws is: TypeError: 'use client'
import { css } from '@/styled-system/css'
import type { VideoProps } from '@/types'
import dynamic from 'next/dynamic'
import type { APITypes } from 'plyr-react'
import 'plyr-react/plyr.css'
import { useRef } from 'react'
const Plyr = dynamic(() => import('plyr-react'), { ssr: false })
export type PlayerProps = {
provider: 'vimeo'
// videoOptions?: any
} & VideoProps
export default function VideoPlayer(props: PlayerProps) {
const { url, provider, _key, title } = props
const ref = useRef<APITypes>(null)
return (
<div key={_key} className={css({ width: '100%', height: '100%', position: 'relative' })}>
<Plyr
ref={ref}
key={_key}
id="plyr-player"
playsInline
source={{
type: 'video',
sources: [
{
src: url,
provider: provider
}
]
}}
// options={videoOptions}
/>
</div>
)
} |
I have created discussing on nextjs repo please add more question and details also there |
When i tried to use react-plyr i bumped into the same issue: Disclaimer: Ignore the rest of the page, is an example test only btw. Debugging into the internal plyr and react-plyr files i finally found the function what is called to initiate the youtube script routine. Logging inside this function, i found a strange behavior, the function was been called twice, but the component or the other items inside they didn't suffered a purposeful re-render, which reminded me about a flag of react, the strict mode flag: According to react docs, this flags causes an re-run on some functions and other items, among then, the functional components. This "get attribute" error occurs just in dev mode because the react strict mode is active by default into next js app router since the version 13.4: Testing and debugging without the strict mode flag, the error doesn't occurs, but this maybe not a good practice. Conclusion: You can still using the react-plyr lib quietly, because this is not a "bug", is more like an scenario where most of us isn't accustomed to work. Even so, the lib must should predict scenarios like that to avoid errors like that caused by a default react behavior. |
When loading a page with a player on localhost, a
TypeError: Cannot read properties of null (reading 'getAttribute')
error pops up.To Reproduce
Steps to reproduce the behavior:
Expected Behavior
No popup error.
Screenshots
Desktop (please complete the following information):
Additional Context
plyr-react
as a dependency in a transpiled Next.js module.Component Source Code
The text was updated successfully, but these errors were encountered: