Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag

Ads
 

Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag

Hi,

I am writing simple reactjs application. Here is my code:

import React, { Component } from 'react';

class App extends Component {
  render() {
    return (

        <p>Hello world! Welcome!! React Tutorials.</p>
         <div id="parent">
            <h1>Header</h1>
            <h2>Content</h2>
            <p>This is the content!!!</p>
         </div>

    )
  }
}
export default App;

But it throws following error:

Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?

How to solve this?

Thanks

View Answers

March 16, 2020 at 12:14 AM

Hi,

This error is coming because you have not included he components in a starting and ending divs.

<div>....</div>

I have changed you code and following is running code:

import React, { Component } from 'react';

class App extends Component {
  render() {
    return (
        <div>
        <p>Hello world! Welcome!! React Tutorials.</p>
         <div id="parent">
            <h1>Header</h1>
            <h2>Content</h2>
            <p>This is the content!!!</p>
         </div>
         </div>
    )
  }
}
export default App;

Thanks

Ads









Related Tutorials/Questions & Answers:
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag ... following error: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? How to solve
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag ... following error: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? How to solve
Advertisements
parsing xml using sax
parsing xml using sax  how to get values if the root elements are same and their attributes are different
ModuleNotFoundError: No module named 'django-jsx'
ModuleNotFoundError: No module named 'django-jsx'  Hi, My Python... 'django-jsx' How to remove the ModuleNotFoundError: No module named 'django-jsx' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'gears-jsx'
ModuleNotFoundError: No module named 'gears-jsx'  Hi, My Python... 'gears-jsx' How to remove the ModuleNotFoundError: No module named 'gears-jsx' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'jsx-lexer'
ModuleNotFoundError: No module named 'jsx-lexer'  Hi, My Python... 'jsx-lexer' How to remove the ModuleNotFoundError: No module named 'jsx... have to install padas library. You can install jsx-lexer python with following
ModuleNotFoundError: No module named 'jsx-lexer'
ModuleNotFoundError: No module named 'jsx-lexer'  Hi, My Python... 'jsx-lexer' How to remove the ModuleNotFoundError: No module named 'jsx... have to install padas library. You can install jsx-lexer python with following
ModuleNotFoundError: No module named 'jsx-lexer'
ModuleNotFoundError: No module named 'jsx-lexer'  Hi, My Python... 'jsx-lexer' How to remove the ModuleNotFoundError: No module named 'jsx... have to install padas library. You can install jsx-lexer python with following
ModuleNotFoundError: No module named 'sphinxcontrib-jsx'
ModuleNotFoundError: No module named 'sphinxcontrib-jsx'  Hi, My... named 'sphinxcontrib-jsx' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-jsx' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'sphinxcontrib-jsx'
ModuleNotFoundError: No module named 'sphinxcontrib-jsx'  Hi, My... named 'sphinxcontrib-jsx' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-jsx' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrapped-exception'
ModuleNotFoundError: No module named 'wrapped-exception'  Hi, My... named 'wrapped-exception' How to remove the ModuleNotFoundError: No module named 'wrapped-exception' error? Thanks   Hi, In your
Struts2.2.1 updownselect Tag Example
Struts2.2.1 updownselect Tag Example The updownselect tag is a UI tag that creates a HTML select component with buttons to move up and down the elements in the select component. When the containing form is submitted, its elements
JSP Elements
JSP Elements In this section we will learn about the JSP elements that we can use on a JSP page. This section will describe you all types of JSP elements that we can use on JSP page. JSP elements are called the JSP tags on JSP page
ModuleNotFoundError: No module named 'redis_wrapped_mkstemp'
ModuleNotFoundError: No module named 'redis_wrapped_mkstemp'  Hi...: No module named 'redis_wrapped_mkstemp' How to remove the ModuleNotFoundError: No module named 'redis_wrapped_mkstemp' error? Thanks   Hi
ModuleNotFoundError: No module named 'parsing'
ModuleNotFoundError: No module named 'parsing'  Hi, My Python... 'parsing' How to remove the ModuleNotFoundError: No module named 'parsing... to install padas library. You can install parsing python with following command
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
XML parsing to Mysql database
XML parsing to Mysql database  Can someone please post the code for parsing an XML file into Mysql database using SAX
Truncating issue while parsing XML with SAX Parser.
Truncating issue while parsing XML with SAX Parser.  I am Parsing one xml file and after parsing I have to enter the data into the database using hibernate. The problem is while parsing some elements, its not getting the complete
ArrayList elements
ArrayList elements  how to print ArrayList elements in reverse order without using predefined methods   import java.util.*; class ArrayListReverse { public static void main(String[] args) { ArrayList
parsing xml with jquery
parsing xml with jquery  Please explain how to parse a xml file into jquery. Thanks
Parsing string in objective c
Parsing string in objective c  Hi, How can i parse a string in Objective c?? Thanks.   Parsing string in objective c This example will also help you to separate the strings separated by one component
Struts 2 Action Tag
Struts 2 Action Tag "action" Tag in Struts 2 is used by developer to call action class from a JSP page. For calling the action class, developer must assign action name. Struts 2 Action Tag is one of the Data Tags, which are used
Parsing date in Java
Parsing date in Java  How can i parse the date in Java in a simple format..?   SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy
Parsing into date object
Parsing into date object  Here is my code: String de = (String) session.getAttribute("licvalid"); DateFormat df = new SimpleDateFormat("yyyy/MM/dd.... But, it is showing error at the line where i performed parsing operation. Please help me
Parsing into date object
Parsing into date object  Here is my code: String de = (String) session.getAttribute("licvalid"); DateFormat df = new SimpleDateFormat("yyyy/MM/dd.... But, it is showing error at the line where i performed parsing operation. Please help me
java parsing of data types
java parsing of data types  Why its not works? char ch; String s=* ch=Character.parseChar(s) program: char op; DataInputStream dis=new DataInputStream(System.in); System.out.print("Enter operator (+,-,*,/,%): "); op

Ads