acornjs / acorn-jsx

Alternative, faster React.js JSX parser
MIT License
646 stars 72 forks source link

Unhelpful error message when forgetting to wrap JSX tags in parent node #19

Closed jcw closed 9 years ago

jcw commented 9 years ago

Consider this:

import React from 'react';

class OnOff extends React.Component {
  render() {
    return (
      <input type="checkbox" id="onoff" />
      <label for="onoff">Enable</label>
    );
  }
}

JSX compiler says Adjacent JSX elements must be wrapped in an enclosing tag but Babel prints Unexpected token (7:13). Also the token it refers to is for argument which is confusing because the actual issue is due to tags not having an ancestor.

See also babel/babel#1008 and gaearon/react-hot-boilerplate#16