DEV Community

Cover image for React setState without Render
Ertugrul DOGAN
Ertugrul DOGAN

Posted on

3 1

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>TAKSİT SEÇENEKLERİ</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>

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay