react-youtube
react-youtube copied to clipboard
Use hooks, support React 18, drop React <16
npm install @u-wave/react-youtube@next
This will be version 1.0 of the library. It uses hooks internally instead of a class. It exposes a useYouTube
hook so you can attach a player to an element that way. <YouTube />
is a very boring wrapper around that hook. The hook also provides easier access to the player instance.
Breaking changes
- The package now requires React 16 or later.
- The package targets modern browsers, it uses ES2015 syntax. Transpile it if you need broader support.
-
showInfo
andsuggestedQuality
props are removed: these were already removed from the YouTube API a few years ago and have had no effect ever since.
Otherwise the API remained exactly the same.
Todo
- [ ] Need to make sure the unmount order with the hook API is right, as the YT SDK has some strict expectations about that.
Node.removeChild: The node to be removed is not a child of this node
The iframe should be destroyed before react tries to unmount it, maybe useLayoutEffect would work.