256 Kilobytes

Answers in Computer Programming | By Some Guy

Published 10 months agoSun, 16 Dec 2018 09:32:31 -0800

230 views, 0 RAMs, and 1 comment

Tags: JavaScript, Errors, JSX, Programming, React, Render

Profile Photo - Some Guy Some Guy
🗎 3224 🗨 41 🐏 31
Subscriber

I keep getting an error that says "Adjacent JSX elements must be wrapped in an enclosing tag" on the JavaSCript. Can anyone help me figure out why i am getting this error message and how to render it?

Download more RAM. 🐏 ⨉ 0 Posted by Some Guy 10 months ago 🕓 Posted at 16 December, 2018 09:32 AM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - Univa Univa
🗎 0 🗨 175 🐏 5
Author

This is a simple solution as you only need to add an enclosing parent element to all components inside the render function. Check out the code below for how we add a parent element for each case.

//CORRECT
 render() {
    return (
      <View>
        <View>
          <Text>My first view</Text>
        </View>
        <View>
          <Text>My second View</Text>
        </View>
      </View>
    );
  }
//CORRECT
render() {
    return (
      <View>
        <Text>My first view</Text>
        <Text>My second View</Text>
      </View>
    );
  }
//CORRECT - rendering a custom component
render() {
    return (
      <View>
        <CustomComponent1 />
        <CustomComponent2 />
      </View>
    );
  }
 
Download more RAM. 🐏 ⨉ 0 Posted by Univa 6 months ago 🕓 Posted at 28 April, 2019 05:23 AM PDT

Hello.

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.