Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for spread operator in JSX (without ES6)

See original GitHub issue

Using the spread operator in JSX should work in any ecma version, but instead you must set the version to 6 (or higher).

Spread is part of the JSX spec: And is supported in JSX by other libraries, such as babel (with babel-preset-react). Acorn has an official plugin that supports this: And espree’s readme has an example, having support for spread in ES5:

Using eslint --init and answering yes to React & JSX generates config that does not allow the spread operator (as ecma version 6 is required, see this issue:

Note: babel (recommended parser) handles the spread operator perfectly in JSX with only babel-preset-react.

What version of ESLint are you using?


What parser (default, Babel-ESLint, etc.) are you using?

eslint with eslint-plugin-react

Please show your full configuration:

Rules do not appear to affect this issue. Only passes with ecma version 6 (or higher).


  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
  "plugins": [

What did you do? Please include the actual source code causing the issue.

Using the spread operator to pass props to a JSX element with ecma version 5

<div {...this.props} />

What did you expect to happen?

This should pass the linting.

What actually happened? Please include the actual, raw output from ESLint.

error Parsing error: Unexpected token

which points to the open brace: {

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

JakeSidSmithcommented, Aug 25, 2016

I don’t mind taking a look if someone can point me in the right direction. 😃

nzakascommented, Aug 13, 2016

This may be an issue with the Acorn plugin that Espree uses, as we delegate to that for parsing JSX. In any event, this should be a bug on Espree.

@kaicataldo that’s for experimental object rest/spread and shouldn’t be used by JSX.

@JakeSidSmith experimental rest/spread flag isn’t used for JSX parsing at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uses of Spread Operator in JavaScript, React. - Medium
Spread operator allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for...
Read more >
Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments...
Read more >
Weird behavior of spread operator in JSX - Stack Overflow
In both cases it is a spread operator only and Javascript spread operator only. There is no such thing as JSX spread operator....
Read more >
React ES6 Spread Operator - W3Schools
The spread operator is often used in combination with destructuring. Example. Assign the first and second items from numbers to variables and put...
Read more >
ES6 Spread Operator in React by Example: Props and setState
The Spread operator lets you expand an iterable like a string, object or array into its elements while the Rest operator does the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found