i'm rendering an string array 'options' as this
<View ref={refInput}>
{options.map((item, index) => (
<View key={index}>
<View style={{ display: "flex", flexDirection: "row" }}>
<TextInput placeholder={item}></TextInput>
{options.length > 2 && index === options.length - 1 && (
<TouchableOpacity onPress={removeOption}>
<Text>Remover</Text>
</TouchableOpacity>
)}
</View>
{index >= options.length - 1 && index < 3 && (
<TouchableOpacity onPress={() => addOption(index)}>
<Text>Adicionar</Text>
</TouchableOpacity>
)}
</View>
))}
</View>
For each element in my array i'm rendering a text input. It starts with 2 and can go up to 4 inputs. What is the best way to get those inputs values?
I passed a ref to the first View that renders the map and i have a function that get that ref by
const input = refInput.current
It returns to me a HTML collection that's a bit complicated to iterate and i don't even know how to type it with typescript.
So is there a better way to get the values?