#react-player breaks on Remix v2

1 messages · Page 1 of 1 (latest)

foggy bridge
#

Started having this issue when I upgraded to Remix v2.

How to reproduce:

  1. Create new Remix app: npx create-remix@latest
  2. Install react-player: npm i react-player
  3. Replace root.tsx with the example from the docs (https://github.com/cookpete/react-player)
import ReactPlayer from 'react-player'

export default function Index() {
  return (
    <div>
      <ReactPlayer url='https://www.youtube.com/watch?v=LXb3EKWsInQ' />
    </div>
  );
}

When I run it I'm getting this error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

However if I call it like this <ReactPlayer.default /> instead of <ReactPlayer /> (I don't even know how I found this out), then it works. Any ideas?

import ReactPlayer from 'react-player'

export default function Index() {
  return (
    <div>
      <ReactPlayer.default url='https://www.youtube.com/watch?v=LXb3EKWsInQ' />
    </div>
  );
}

I'm a typescript noob so I'm not sure what's going on here. Thanks!

tribal cove
#

I am not sure why it works, may i ask why you don't just use CRA if you don't want a server side rendered application?