Skip to content
Advertisement

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

Here is my code:

JavaScript

The error appears at the first character of the opening tag for the breakline HTML element. I do not understand why this is happening as I have code elsewhere that uses the same principle and has no errors at all.

Advertisement

Answer

These elements, inside the curly braces, need to be wrapped inside of a <React.Fragment /> (<> and </> for short)

https://reactjs.org/docs/fragments.html

Your code:

JavaScript

Corrected code:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement