Frequently asked questions
›Why does JSX need className instead of class?
JSX compiles to JavaScript, where class is a reserved word, so React uses the DOM property names: className, htmlFor, tabIndex, readOnly… The converter renames all of them, including SVG attributes such as stroke-width (strokeWidth).
›What happens to inline onclick handlers?
They become arrow functions with the same code, for example onClick={() => { save() }}, and a warning reminds you to move that logic into the component.
›What does the defaultValue option do?
In React, value and checked make a field controlled and need an onChange handler. With the option enabled they become defaultValue and defaultChecked, which keep the HTML behaviour.