plyr-react ref.current.plyr.on is not a function

854 Views Asked by At

I'm using react function component and plyr-react version 3.2.1.

getting error ref.current.plyr.on is not a function

In 3.1.0 and below version it's working fine

Stackblitz Link - https://stackblitz.com/edit/react-vv9haf

CODE

const PlayerView = () => {
const ref = useRef();
 useEffect(() => {
  ref.current.plyr.on("ended", (event) => {
  console.log("ended-event");
 })
}, [])

 return (
 <Plyr
  id="player"
  options={{ ...options, controls }}
  source={src}
  ref={ref}
 />
);
1

There are 1 best solutions below

4
Vida Hedayati On

Please try it

ref?.current?.plyr?.on