question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Player rendering empty div

See original GitHub issue

Current Behavior

My video component looks like this:

// https://github.com/cookpete/react-player/issues/1428
import dynamic from 'next/dynamic'
const ReactPlayer = dynamic(() => import('react-player/lazy'), { ssr: false })

export default function Video({src}) {
  return <ReactPlayer src={src} />
}

I use it like this:

<Video src="https://www.youtube.com/watch?v=grHP-de1p-U" />

Instead of seeing the video rendered on my page, I’m getting a blank div, in my dev tools I see:

<div src="https://www.youtube.com/watch?v=grHP-de1p-U" style="width: 640px; height: 360px;"></div>

Expected Behavior

See the video rendered on my page.

Environment

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
daniele-sarnari-blinkoocommented, Nov 29, 2022

I could be wrong but the supplied example uses src, not url when defined in React Player

Does the following work?

// https://github.com/cookpete/react-player/issues/1428
import dynamic from 'next/dynamic'
const ReactPlayer = dynamic(() => import('react-player/lazy'), { ssr: false })

export default function Video({src}) {
  return <ReactPlayer url={src} />
}

I am experiencing an empty src in my video tag similar to @daniele-sarnari-blinkoo when trying to use a local file but all remote URLs appear to be working correctly (I’m using 2.11.0)

I always used url property. In my case the problem was React Strict Mode https://reactjs.org/docs/strict-mode.html.

2reactions
daniele-sarnari-blinkoocommented, Sep 19, 2022

Similar problem with 2.11.0 version image 2.10.1 is working

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - React rendering empty - Stack Overflow
i am new to react. I read documentation and tried to research my problem. i am curious why my page keeps rendering empty...
Read more >
Preserving and Resetting State - React Docs
The counter state gets reset when you click the checkbox. Although you render a Counter , the first child of the div changes...
Read more >
React.createElement() > React with Symfony - SymfonyCasts
The existing app is rendered in this js-rep-log-table element. Above this, add a new <div class="row"> and inside, an empty div we can...
Read more >
Building a Video Player with React and Material UI
React player is a component used in rendering various video ... Navigate to your App.css file and style the Player Div using the...
Read more >
empty - CSS: Cascading Style Sheets - MDN Web Docs
1. div:empty { ; 2. outline: 2px solid deeppink; ; 3. height: 1em; ; 4. } ; 5. ​ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found