import React, { useCallback, useEffect, useMemo, useState } from "react"; import { View, Text, TextInput, TouchableOpacity, StyleSheet, Button, ColorValue, Modal, } from "react-native"; const colors: ColorValue[] = ["white", "red", "green", "blue", "black"]; const ChipInputModal = ({ showModal, setShowModal, totalChipsCount, update, }: { showModal: [boolean, ColorValue]; setShowModal: React.Dispatch>; totalChipsCount: number[]; update: Function; }) => { const color: ColorValue = useMemo(() => showModal[1], [showModal]); const colorIdx = useMemo(() => colors.indexOf(color), [color]); const value: number = useMemo( () => totalChipsCount[colorIdx], [totalChipsCount, colorIdx] ); return ( setShowModal([false, color])} > Number of {showModal[1]?.toString()} chips { const n = parseInt(v); update(showModal[1], Number.isNaN(n) ? 0 : n); }} />