Use PropTypes to Define the Props You Expect no result using CRA

Use PropTypes to Define the Props You Expect no result using CRA
0
#22

Yup, he has, I was talking to him about it. It’s totally fine to use class, I think the aim going forward is to completely drop className, but at the minute in React 16.whatever class should work perfectly with the caveat that you get those warnings in the console.

1 Like

#23

Found the answer: It works as of React 16 because React doesn’t deal with unknown attributes, it passes them on to the DOM.

[UPDATE]: Forgot to link to the relevant blog post:

  • Known attributes with a different canonical React name:
<div tabindex="-1" />
<div class="hi" />

React 15: Warns and ignores them.
React 16: Warns but converts values to strings and passes them through. Note: always use the canonical React naming for all supported attributes.

0 Likes

#24

Ah yes, that’s why the waning come out like that! I think it fixes a load of PITA issues (ARIA attributes for example are miles easier to use)

1 Like