Search code examples
javascripthtmlreactjsdomcamelcasing

Why do I need to CamelCase Html Attributes in React?


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?


Solution

  • 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