Both of the following code snippets define a simple React component that renders a <h1> element with the text Hello React.
However, there are some subtle differences between the two, mainly in how the components are defined and exported.
1: Function Component
2. Arrow Function
Hoisting
Function declarations are hoisted and they can be used before the point in the code at which they are declared.
Arrow functions, being expressions assigned to variables, are not hoisted.
More info about hoisting are available in the Variable Scopes lesson
Both components will be exported as default, allowing importing them without using curly braces:
You will find more information about module imports and exports in the next lesson.