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 content originally appeared on DEV Community and was authored by Ertugrul DOGAN

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>


This content originally appeared on DEV Community and was authored by Ertugrul DOGAN


Print Share Comment Cite Upload Translate Updates
APA

Ertugrul DOGAN | Sciencx (2022-06-20T21:45:04+00:00) React setState without Render. Retrieved from https://www.scien.cx/2022/06/20/react-setstate-without-render/

MLA
" » React setState without Render." Ertugrul DOGAN | Sciencx - Monday June 20, 2022, https://www.scien.cx/2022/06/20/react-setstate-without-render/
HARVARD
Ertugrul DOGAN | Sciencx Monday June 20, 2022 » React setState without Render., viewed ,<https://www.scien.cx/2022/06/20/react-setstate-without-render/>
VANCOUVER
Ertugrul DOGAN | Sciencx - » React setState without Render. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/06/20/react-setstate-without-render/
CHICAGO
" » React setState without Render." Ertugrul DOGAN | Sciencx - Accessed . https://www.scien.cx/2022/06/20/react-setstate-without-render/
IEEE
" » React setState without Render." Ertugrul DOGAN | Sciencx [Online]. Available: https://www.scien.cx/2022/06/20/react-setstate-without-render/. [Accessed: ]
rf:citation
» React setState without Render | Ertugrul DOGAN | Sciencx | https://www.scien.cx/2022/06/20/react-setstate-without-render/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.