Arrow functions

In React, there are a few different ways that you can create a component. One way is to use a named function, which is simply a function that has a name and is declared using the `function` keyword. For example:

function MyComponent() {
return (
<Text>Hello React Native</Text>
);
}

Another way to create a component is to use an arrow function, which is a short, concise way of defining a function. Arrow functions are similar to named functions, but they are declared using the => syntax. For example:

const MyComponent = () => {
return (
<Text>Hello React Native</Text>
);
}

If your component only contains a single, simple expression, you can use an arrow function with an implicit return. This means that you don't need to use the return keyword, and the value of the expression will be automatically returned by the function.

// ⚠️ there is no `return` because we have an implicit return

const MyComponent = () => (
<Text>Hello, world!</Text>
);

Subscribe?

Be the first to receive insightful articles and actionable resources that help you to elevate your skills.