React components and JSX
- A function component takes a properties object and returns
a React element.
- Be careful:
- Components must begin with a capital letter; otherwise
they will be interpreted as DOM tags
- If specifying a class name in JSX, use className instead of class,
since the latter is already a keyword in JavaScript
- Property/attribute names are in camelcase, e.g., onClick instead of onclick
- Use curly braces around JavaScript expressions to get their values
- Always use open and closing tags, e.g., <Welcome/>
- Uses braces with return to prevent automatic semi-colon insertion
- Components must return an element, such as a div, or you can
use empty tags (<> and </>)
More information: https://reactjs.org/docs/components-and-props.html
Exercise: Create a component and use it to display: "My name is name" in the div below