InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

React FAQ

  • JSXTransformer vs babel
  • React.render vs ReactDOM.render
  • React.DOM factory methods
  • Error - Adjacent JSX elements must be wrapped
 
  • Home
  • > Tutorials
  • > Javascript
  • > React
  • > React FAQ

React – How to fix SyntaxError – Adjacent JSX elements must be wrapped in an enclosing tag

on Feb 10, 2016

React element can return only one element. In case you have the following code, you will get “Adjacent JSX elements must be wrapped in an enclosing tag” syntax error.

var MyList = React.createClass({
  render: function() {
    return (
        <h1>something</h1>
        <div>
          something else
        </div>
    );
  }
});

To fix this, you can wrap multiple elements in one outer div as shown below:

var MyList = React.createClass({
  render: function() {
    return (
      <div>
        <h1>something</h1>
        <div>
          something else
        </div>
      </div>
    );
  }
});

Suggested posts:

  1. React jsx hello world with offline transformation
  2. React – JSXTransformer vs babel – which one should be used?
  3. Python xrange examples
  4. React.render vs ReactDOM.render – which one should be used?
  5. PHP array map example
  6. CSS transform – skew (skewX and skewY)
  7. React basic clock example using setInterval
  8. React component tutorial with click handler – javascript version
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged React FAQ, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress