Hello I am stuck on this issue where I can’t figure out how to do inline if else statment in react native.
{currentSlideIndex == 0 ? (
<>
<KeyboardAvoidingView style={{flex:1}} behavior='position'>
<BlurView intensity={20} tint="light" >
<Text style={styles.label}>Name</Text>
<TextInput
value={name}
onChangeText={onNameChange}
style={styles.input}
/>
</BlurView>
</KeyboardAvoidingView>
</>
):(
<>
<KeyboardAvoidingView style={{flex:1}} behavior='position'>
<BlurView intensity={20} tint="light" >
<Text style={styles.label}>Surname</Text>
<TextInput
value={name}
onChangeText={onNameChange}
style={styles.input}
/>
</BlurView>
</KeyboardAvoidingView>
</>
)}
I want it to make it so that I have currentslideIndex == 0 , currentslideIndex == 1 ,currentslideIndex == 2.
>Solution :
Try this code below:
{
currentSlideIndex == 0 ? (
<>
{/* code for slide 0 */}
</>
) : (currentSlideIndex == 1 ? (
<>
{/* code for slide 1 */}
</>
) : (
<>
{/* code for slide 2 */}
</>
)
)
}