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

navigator is not defined

Open romanown opened this issue 6 years ago • 7 comments

when I go to the page with the video from the main page of the site it works well. but when I go to the page with the video on a direct link then such an error. ReferenceError: navigator is not defined at /var/www/dfor.ru/node_modules/react-html5video/dist/index.js:2496:61 at Video.render (/var/www/dfor.ru/node_modules/react-html5video/dist/index.js:259:35)

romanown avatar Jun 22 '18 07:06 romanown

I get the same thing

gazreese avatar Jul 16 '18 14:07 gazreese

Sounds like you're both server side rendering. A video can't be server side rendered. You should check and render a placeholder when rendering on the server.

mderrick avatar Jul 19 '18 10:07 mderrick

Thank You for Youre answer. Can You changing this component for control this problem?

-- Roman

romanown avatar Jul 19 '18 10:07 romanown

Is there a solution to this problem? Hope reply

kkk-s1 avatar Aug 07 '18 10:08 kkk-s1

@Brightchild @romanown @mderrick We encountered the same problem. Is a typical issue with server side rendering and some libs that make use of things like navigator or window. So I implemented a simple fix and submitted a PR #142 with it. Hope it'd help you guys as much as it helped us.

jonanderdev avatar Jan 23 '19 12:01 jonanderdev

thank you. I deleted this line and it works for me. of course Your decision is more correct.

romanown avatar Jan 23 '19 13:01 romanown

Anyone else finding themselves here: since there PR was never merged a different workaround I found was to use the react-no-ssr package and wrap the <video> tags within a <NoSSR> tag. Ugly but it stopped stuff from breaking.

Hope this helps someone.

twotabsofacid avatar Aug 16 '23 23:08 twotabsofacid