I am very new in react native . i am building a module which increment the state hook variable and render it in my input , but the counter did't render it after 1,meanz when i click on plus button it increment the counter to 1 but after that if i re-press the plus button it did't change the value 1 to 2. here is my code snippet of my input and plus button.
<View style={{flex:1 ,flexDirection: 'row', backgroundColor: '#ebedf087',width: '100%' }} >
<View >
<Pressable onPress={ () => { addQtyItem( loadName , cardId ) } } style={{backgroundColor: Colors.primary,padding: 8}}>
<Icon name='plus' type='font-awesome' style={{fontSize: 25,color: 'white', textAlign: 'center'}} />
</Pressable>
</View>
<View style={{width: 87}}>
<TextInput value={ (UpdateQtyofItem[loadName+'__'+cardId] != undefined) ? (UpdateQtyofItem[loadName+'__'+cardId].value).toString() : '0' } key={cardId} onChangeText={(value) => { getinputValue( loadName , cardId , value ) }} placeholder="Qty" style={{textAlign: 'center'}} />
</View>
<View style={{backgroundColor: 'red',padding: 8}}>
<Icon name='minus' type='font-awesome' style={{fontSize: 25,color: 'white', textAlign: 'center'}} />
</View>
</View>
code snippet of addQtyItem function.
const [ UpdateQtyofItem , setUpdateQtyofItem] = useState({});
function addQtyItem(loadName , cardId){
let loadedName = loadName+'__'+cardId;
if( selectedLoadArray[loadedName] != undefined ){
selectedLoadArray[loadedName].value = (selectedLoadArray[loadedName].value+1);
}else{
selectedLoadArray[loadName+'__'+cardId] = {'value' : 1 ,'cardId' : cardId};
}
setUpdateQtyofItem(selectedLoadArray)
}