News for hackers. Stuff that matters.
Re:YouTube Video as Background in React by ht85 on Sunday March 27, 2022 @06:53AM (#30819291)
- no documentation, not even a few lines

- no example without cloning

- example provided doesn't run without modifying it (empty video url)

- no tests

- doesn't look maintained (e.g. 3 years old typescript version)

Then looking at index.tsx

- using Class as component (debatable but really not idiomatic anymore)

- weird empty lines and spaces

- weird `this.container` pattern, not to mention the type of it is unsafe

- `aspectRatio` has to be in `x:y` format (including the colon), no way to know that unless you read the code in depth (also weird choice)

- using the anti-pattern of setting derived state (aspectRatio) in this.state, rendering again with a different aspect ratio won't work

- componentWillUnmount does not remove the listener, as calling `.bind` there will create a function that doesn't match the one in componentDidMount

- using `.bind` inline insted of using fat arrows directly when creating class methods

- the weird syntax for `playerProps =`

- hard coding some of the `PlayerVars` props instead of just makin props `PlayerVars & { ... }` to allow passing any props supported by react-youtube

Anyway that's just at a glance, I'm sure cloning the project and trying to use it would reveal a lot more.

There are no comments on this comment yet.