1

I'm using react-player to make a responsive web player app to get the stats about playedTime and all that stuff using a callback prop onProgress. But when I'm writing the code to useState, it gives a Parsing Error saying Unexpected Token, Expected ";" Also I am new to using GatsbyJs so if the error is because of that, I wouldn't have known. Here's my piece of code:-

const Lesson = () => {
  const [watchComplete, setWatchComplete] = useState{false}

  const handleWatchComplete = ({ played }) => {
    console.log(played)
  }

  return (
    <div>
      <ResponsivePlayer
        url="https://www.youtube.com/watch?v=ovJcsL7vyrk"
        onProgress={handleWatchComplete}
      />
    </div>
  )
}

export default Lesson

1 Answers1

1

You have a typo in your useState declaration.

Change this:

  const [watchComplete, setWatchComplete] = useState{false}

To this:

  const [watchComplete, setWatchComplete] = useState(false)
Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67