Line 15:1: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?
13 | //crossorigin></script>
14 |
> 15 | <script>var Alert = ReactBootstrap.Alert;</script>
| ^
Asked
Active
Viewed 35 times
-1

大陸北方網友
- 3,696
- 3
- 12
- 37

Ikshul Dureja
- 67
- 1
- 8
-
1Somewhere in a component's render you have adjacent jsx elements (like the error is telling you). So you need to wrap those in a parent element, like a View or Fragment. – 5eb Jul 24 '20 at 08:21
-
1Does this solve your issue: https://stackoverflow.com/questions/31284169/parse-error-adjacent-jsx-elements-must-be-wrapped-in-an-enclosing-tag – Drew Reese Jul 24 '20 at 08:24
1 Answers
0
Somewhere in your code you're doing:
const Example = () => (
<div />
<div />
)
You cannot do that. React can only returns one parent element. So you have to wrap it with another div
:
const Example = () => (
<div>
<div />
<div />
</div>
)
However, this will bloat your markup with another div
which is just to satisfy React. So you can use React.Fragment
so that your markup doesn't have an unnecessary div
like:
const Example = () => (
<React.Fragment>
<div />
<div />
</React.Fragment>
)
Or in short, you can write it as:
const Example = () => (
<>
<div />
<div />
</>
)

Dharman
- 30,962
- 25
- 85
- 135

deadcoder0904
- 7,232
- 12
- 66
- 163
-
This answer is a slightly edited version of the top answer here https://stackoverflow.com/questions/31284169/parse-error-adjacent-jsx-elements-must-be-wrapped-in-an-enclosing-tag. Maybe it's just better to close the question. – 5eb Jul 24 '20 at 10:33
-