- Let's start with the Button/index.js file. First, we'll import all the dependencies for this component:
import React, { Component } from 'react';import { ActivityIndicator, LayoutAnimation, StyleSheet, Text, TouchableOpacity, View,} from 'react-native';
- We're going to use only four props for this component: a label, a loading Boolean to toggle displaying either the loading indicator or the label inside the button, a callback function to be executed when the button is pressed, and custom styles. Here, we'll init the defaultProps for loading to false, and the
handleButtonPress to an empty function:
export default class Button extends Component { static defaultProps = { loading: false, onPress: () => {}, }; // Defined ...