question-mark
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.

Spread children not supported

See original GitHub issue
const F = () => <a>{...[]}</a>;

crashes sucrase with:

Error transforming sample.tsx: Unterminated regular expression (1:29)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
alangpiercecommented, Mar 11, 2019

I just released a fix for this in 3.10.0.

2reactions
yangcommented, Feb 27, 2019

Yeah I’m using React. FWIW this is syntax that Typescript supported. My understanding of this syntax is that it’s for places where you have an array but know it’s actually static and unchanging, so that keys are not necessary (so React can spread them out as if they were positional args to createElement). It’s also useful when you’re transplanting children from one place to another.

I don’t know why Babel chokes on this, though I’ve seen a higher rate of bugs in Babel than TSC so far since the switch in create react app 2.0 (random example).

Thanks!

On Fri, Feb 22, 2019 at 7:14 AM Alan Pierce notifications@github.com wrote:

Interesting, I actually hadn’t seen that syntax. FWIW, Babel (with the React transform) throws an exception, saying “Spread children are not supported in React” (repl https://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=FAYw9gdgzgLgBAMTgXjgCgJQoHxwDwCG2A3gHTkDaAugL54D0RA3EA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.3.3). Are you using something other than React? I think React wants you to pass an array there so it knows to check that you’re using keys properly.

Regardless, I think it’s within Sucrase’s scope to just compile it and let other tools do the error checking, so this certainly seems reasonable to implement.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alangpierce/sucrase/issues/420#issuecomment-466430814, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAb2V-Vv--U8HfQQBqxWfTL8e9voKBEks5vQAlPgaJpZM4bGMwh .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spread children are not supported in React : r/reactjs - Reddit
The one that's causing the error, is that you are trying to render the rest arguments, rather than passing them as props to...
Read more >
React.js - this.props.children an object when spreading the ...
children is converting to an object when I spread the result of a .map() from the parent. example: const items = [ {...
Read more >
React Children And Iteration Methods - Smashing Magazine
While working with React, most of the time we do not touch the children prop any more than using it in React components...
Read more >
Using Children in React - We Learn Code
Using Children in React. You can use props.children in React in order to access and utilize what you put inside the open and...
Read more >
Schools and Childcare Programs | COVID-19 - CDC
See ongoing mitigation guidance and prevention and support for ... the spread of COVID-19 and maintain safe operations in schools, child care programs, ......
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found