O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to create a form component

Every application requires a way to input data, whether it's a simple registration and login form or a more complex component with many input fields and controls.

In this recipe, we will create a form component to handle text inputs. We will collect data using different keyboards and show an alert message with the resulting information.

Getting ready

We need to create an empty app using the React Native CLI, and we will name it FormComponents.

How to do it...

  1. We will start by bootstrapping our app. Let's open the index.ios.js and index.android.js files and add the following code:
            import React from 'react';        import MainApp from './src/MainApp';        import { AppRegistry } from 'react-native';        AppRegistry.registerComponent('FormComponents', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required