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

TypeError: init is not a function

Open stv8 opened this issue 3 years ago • 3 comments

Be sure to search for your issue before opening a new one.

Hello, I'm not sure what's going on, but the component simply isn't working in my create-react-app setup. I tried uninstalling and reinstalling all node_modules as well.

Current Behavior

  • React is erroring whenever I try to use ReactPlayer
  • I am using it like so
import React from "react";
import ReactPlayer from "react-player";
import Box from "@material-ui/core/Box";

export default function Playground() {
  return (
    <Box>
      <ReactPlayer url="https://www.youtube.com/watch?v=iB2RT-hyD58" />
    </Box>
  );
}

And receiving this error image

Expected Behavior

  • I expected the component to work

Steps to Reproduce

  1. I simply installed the package, imported it into a component, and it fails.

Environment

  • URL attempting to play: see code snippet above
  • Browser: Firefox 90.0b3
  • Operating system: MacOS 11.2.3 (20D91)
  • "react-player": "^2.9.0" (Create React App)
  • React: 16.13.1

Other Information

stv8 avatar Jun 14 '21 15:06 stv8

Same problem but in Windows with React 16.12.0. I tried with the last version 17.0.2 and it worked. So, the version 16.6 that is told on the migration guide I think is incorrect.

TiagoSousa26 avatar Jul 26 '21 10:07 TiagoSousa26

遇到同样的问题 image 这样的配置能够运行。 但是 image 这样的配置就会报错: image

Mluocheng avatar Nov 22 '21 08:11 Mluocheng

The implementation of React.lazy has changed. React16.13 has no init property,but React16.14 and React17 has init property.

my workaround for this is to fork the repo and update the react version to latest npm install react@latest react-dom@latest

build by running npm run prepublishOnly

and install by npm install directory-to-repo

Adrian-stuff avatar Mar 22 '22 23:03 Adrian-stuff