Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 20, 2022 09:45 pm GMT

React setState without Render

Since setstate is defined in onpress, it renders again and the ones with input are deleted.

<View style={styles.container}>
<View>
<Text>TAKST SEENEKLER</Text>
</View>
{this.state.List.map((item, key) => {
return (
<TouchableOpacity
style={styles.paymentItemTaksit}
key={key}
onPress={() => {
this.setState({
checked: key,
taksitsayisi: item.value,
surcharge: (cart.total * item.value) / 100,
});
}}>
<View style={styles.shippingItemTitle}>
{this.state.checked === key ? (
<View>
<Icon
name="radio-button-checked"
style={styles.checkIcon}
/>
{item.value == 1 ? (
<Text style={styles.paymentItemText}>
{item.taksit} {cart.total} {cart.total}
</Text>
) : (
<Text style={styles.paymentItemText}>
{item.taksit}{' '}
{(
(cart.total + (cart.total * item.value) / 100) /
item.value
).toFixed(2)}{' '}
{(
cart.total +
(cart.total * item.value) / 100
).toFixed(2)}
</Text>
)}
</View>
) : (
<View>
<Icon
name="radio-button-unchecked"
style={styles.uncheckIcon}
/>
{item.value == 1 ? (
<Text style={styles.paymentItemText}>
{item.taksit} {cart.total} {cart.total}
</Text>
) : (
<Text style={styles.paymentItemText}>
{item.taksit}{' '}
{(
(cart.total + (cart.total * item.value) / 100) /
item.value
).toFixed(2)}{' '}
{(
cart.total +
(cart.total * item.value) / 100
).toFixed(2)}
</Text>
)}
</View>
)}
</View>
</TouchableOpacity>
);
})}
</View>


Original Link: https://dev.to/ertugruldogan/react-setstate-without-render-5aj7

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To