Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment? | Technical, Finance, Investment Questions

Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment?

Priya Singh

7 months ago

While developing my Android APP with React Native, I was getting this error frequently.


Solution:


When we write any condition in React Native code, each and every block must have code inside a <DIV> like below.



Sample Code:


{tenants.length == 0 ? (<View><Text style={styles.heading}>You have no Tenants</Text>

      <Button

        title="Add Tenant"

        style={styles.buttonStyleApprove}

        onPress={() => navigationService.navigate('AddTenant')}

        /></View>) : <View><Text style={styles.heading}>You have {tenants.length} Tenants</Text></View>

}



Error Logs:


 ERROR [Error: TransformError SyntaxError: C:\XELOXO\GIT\Property\APP\HousePerSqft\xeloxo-home-mobile\App\Screens\PropertyTab\index.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (53:6)


Priya Singh

Business Analyst at HCL Singapore

7 months ago

Featured Blogs
not found

Category: Investment

Author: Sushmita Pal

Posted : 15 hours ago

0( 0 Comments )
not found

Category: Investment

Author: Sushmita Pal

Posted : 3 days ago

0( 0 Comments )
not found

Category: Investment

Author: Sushmita Pal

Posted : 4 days ago

60( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 5 days ago

50( 0 Comments )
not found

Category: Investment

Author: Anushka Trivedi

Posted : 5 days ago

32( 0 Comments )
not found

Category: Investment

Author: Anushka Trivedi

Posted : 6 days ago

64( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 10 days ago

142( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 14 days ago

122( 0 Comments )
not found

Category: Technology

Author: Sweety Singh

Posted : 14 days ago

173( 0 Comments )
not found

Category: Stocks

Author: Sweety Singh

Posted : 16 days ago

69( 0 Comments )
Featured Questions