babel / babylon

PSA: moved into babel/babel as @babel/parser -->
https://github.com/babel/babel/tree/master/packages/babel-parser
MIT License
1.71k stars 258 forks source link

React 16 SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag #744

Closed pronevich closed 7 years ago

pronevich commented 7 years ago

Question: maybe exists babylon beta that supports return array of elements in React 16 ?

hzoo commented 7 years ago

Hey @pronevich! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

nicolo-ribaudo commented 7 years ago

Hi, can you fill the issue template which GitHub shows when you create a new issue? Specifically, what is your input code? It should be something like this:

render() {
  return [
    <A />,
    <B />
  ]
}
loganfsmyth commented 7 years ago

Assuming you're talking about something like https://github.com/facebook/jsx/pull/93, nothing is official yet, and the is no new syntax in Babel at this time. Using an actual array as mentioned above is the way to go.

pronevich commented 7 years ago

Thanks guys, I got it and reinstall modules solve issue

AleCaste commented 7 years ago

Hi @pronevich , how did you fix the issue? I upgraded to React v16 and even though I am rendering an array with keys, I am still getting this error. I updated all babel modules and still getting the error!

pronevich commented 7 years ago

@AleCaste maybe you miss comma between components in array?

AleCaste commented 7 years ago

Wowwwwwww!!!!.... That was exactly it! Silly stupid me. I am sure others will make the same mistake; it's so easy to forget that especially if you are refactoring code for React v16 Thanks!!!