Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React native inline if statments

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this code below:

    {
        currentSlideIndex == 0 ? (
            <>
                {/* code for slide 0 */}
            </>
        ) : (currentSlideIndex == 1 ? (
            <>
                {/* code for slide 1 */}
            </>
        ) : (
                <>
                    {/* code for slide 2 */}
                </>
            )
        )
    }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading