create-universal-package icon indicating copy to clipboard operation
create-universal-package copied to clipboard

Fails to build saying "Unexpected token, expected "," " when it hits React context component

Open Choongkyu opened this issue 6 years ago • 2 comments

I found that when I run into this code:

<Foo.Consumer>
{({bar}) => bar

I get an error Unexpected token, expected "," (61:26) which is where the . that splits the Foo and Consumer is. I am guessing that this does not recognize more recent React syntax since removing that makes the error go away.

Choongkyu avatar Apr 19 '19 06:04 Choongkyu

Facing the same issue, with any JSX

anantkamath avatar May 30 '19 09:05 anantkamath

Cup v4 now uses vanilla .babelrc for Babel configuration (rather than .cuprc.js). Configuration loading as of Babel v7 fixed a lot of the issues (the original reasoning for not using .babelrc in the first place). So assuming you have the React Babel preset in there, it will be able to parse these files.

rtsao avatar May 30 '19 18:05 rtsao