Another common element you'll see in web forms is checkboxes. React Native has a Switch component that works on both iOS and Android. Thankfully, this component is a little easier to style than the Picker component. Let's look at a simple abstraction you can implement to provide labels for your switches:
import React from "react";
import PropTypes from "prop-types";
import { View, Text, Switch } from "react-native";
import styles from "./styles";
export default function CustomSwitch(props) {
return (
<View style={styles.customSwitch}>
<Text>{props.label}</Text>
<Switch {...props} />
</View>
);
}
CustomSwitch.propTypes = {
label: PropTypes.string
};
Now, let's learn how we can use a couple of switches to control application state:
import React, { useState } from "react";
import { View } from "react-native";
import styles from "./styles"...