Function Components

    Minimal example

    A function component is a function that returns a React element.

    Composing components

    We can use custom components like MyComponent in the same way as built-in ones like View. We use props to communicate between components.

    TypeScript types

    We typically create a Props type.

    We typically don't set the type of the return value, since it can generally be inferred and doesn't provide much useful type safety.

    For more detail: https://github.com/typescript-cheatsheets/react-typescript-cheatsheet#function-components

    Component behaviors

    We use hooks to add functionality to function components. Hooks are specially implemented functions that typically start with the prefix use.

    React provides ~10 built-in hooks, but we can also build our own. We'll talk much more about hooks later.

    Want to learn React Native in-depth?

    If you like React Native Express, you'll love my new book, Fullstack React Native: The complete guide to React Native! Throughout the book, we'll build 7 full apps, covering complex topics like navigation, gestures, and native modules. We don't assume any knowledge of React or newer JavaScript language features, so you can dive right in regardless of your experience level. The book comes in PDF, EPUB and MOBI formats.

    Looking for more help?

    Infinite Red sponsors React Native Express and is the premier React Native agency. They're also the team behind the React Native newsletter, podcast, and conference listed here. Get in touch at infinite.red/react-native for a proposal on your next project!