Remove item from array work only on last item rendered but item selected deleted from list
const [otherPhones, setOtherPhones] = useState([]);
{otherPhones.map((item, i) => {
return (
<View
style={{
...DefaultStyles.iconContainer,
marginBottom: hp("1.25%")
}}
key={i}
>
<PhoneNumberPicker
placeholder={i18n.t("other_phone")}
style={{ flex: 10 }}
countryHint={countryHint}
onChange={value => {
_handleOtherPhone(value, i);
}}
/>
<IconButton
style={{ flex: 1 }}
icon="trash-can-outline"
color={SECONDARY}
size={SCALE_20}
onPress={_deleteOtherPhone.bind(this, i)}
/>
</View>
);
})}
const _deleteOtherPhone = index => {
const temp = [...otherPhones];
temp.splice(index, 1);
setOtherPhones(temp);
};
When i delete PhoneNumberPicker and display only simple property item everything work fine. PhoneNumberPicker it's a TextInput with some additional component.