Home > Enterprise >  Why do I need to CamelCase Html Attributes in React?
Why do I need to CamelCase Html Attributes in React?

Time:10-24

Why do I need to camelcase these HTML properties in react:

<video autoPlay loop muted playsInline>
    <source src={url} type="video/mp4" />
</video>

Why is it autoPlay and not autoplay? Or is this an error in my VSCode warnings?

CodePudding user response:

Javascript is case sensitive, so it might just not work with autoplay or playsinline.

But for this case, I think that this is just some common eslint (or some similar tool) warning, you can make sure by just passing those props in lowercase and see if it works

CodePudding user response:

Because thats how attribute in video-react-js library is named. Your vs code works fine.

https://video-react.js.org/components/player/

  • Related