Error with "Put Logic in a Render Function"


#1

https://www.codecademy.com/courses/react-101/lessons/react-components-advanced-jsx/exercises/render-function-calculations?action=lesson_resume

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.
/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^

SyntaxError: /home/ccuser/workspace/react-101-react-components-advanced-jsx-render-function-calculations/app.js: Unexpected token (1:1)
e[0me[31me[1m>e[22me[39me[90m 1 | e[39me[33m<e[39me[33m>e[39me[36mimporte[39m e[33mReacte[39m from e[32m’react’e[39me[33m;e[39m
e[90m | e[39m e[31me[1m^e[22me[39m
e[90m 2 | e[39me[36mimporte[39m e[33mReactDOMe[39m from e[32m’react-dom’e[39me[33m;e[39m
e[90m 3 | e[39m
e[90m 4 | e[39me[36mconste[39m friends e[33m=e[39m [e[0m
at Parser.pp$5.raise (/home/ccuser/node_modules/babylon/lib/index.js:4454:13)
at Parser.pp.unexpected (/home/ccuser/node_modules/babylon/lib/index.js:1761:8)
at Parser.pp$9.jsxParseIdentifier (/home/ccuser/node_modules/babylon/lib/index.js:7029:10)
at Parser.pp$9.jsxParseNamespacedName (/home/ccuser/node_modules/babylon/lib/index.js:7040:19)
at Parser.pp$9.jsxParseElementName (/home/ccuser/node_modules/babylon/lib/index.js:7055:19)
at Parser.pp$9.jsxParseOpeningElementAt (/home/ccuser/node_modules/babylon/lib/index.js:7145:20)
at Parser.pp$9.jsxParseElementAt (/home/ccuser/node_modules/babylon/lib/index.js:7169:29)
at Parser.pp$9.jsxParseElement (/home/ccuser/node_modules/babylon/lib/index.js:7224:15)
at Parser.parseExprAtom (/home/ccuser/node_modules/babylon/lib/index.js:7236:21)
at Parser.pp$3.parseExprSubscripts (/home/ccuser/node_modules/babylon/lib/index.js:3494:19)
at Parser.pp$3.parseMaybeUnary (/home/ccuser/node_modules/babylon/lib/index.js:3474:19)
at Parser.pp$3.parseExprOps (/home/ccuser/node_modules/babylon/lib/index.js:3404:19)
at Parser.pp$3.parseMaybeConditional (/home/ccuser/node_modules/babylon/lib/index.js:3381:19)
at Parser.pp$3.parseMaybeAssign (/home/ccuser/node_modules/babylon/lib/index.js:3344:19)
at Parser.parseMaybeAssign (/home/ccuser/node_modules/babylon/lib/index.js:6433:24)
at Parser.pp$3.parseExpression (/home/ccuser/node_modules/babylon/lib/index.js:3306:19)
at Parser.pp$1.parseStatement (/home/ccuser/node_modules/babylon/lib/index.js:1906:19)
at Parser.parseStatement (/home/ccuser/node_modules/babylon/lib/index.js:5910:22)
at Parser.pp$1.parseBlockBody (/home/ccuser/node_modules/babylon/lib/index.js:2268:21)
at Parser.pp$1.parseTopLevel (/home/ccuser/node_modules/babylon/lib/index.js:1778:8)
at Parser.parse (/home/ccuser/node_modules/babylon/lib/index.js:1673:17)
at parse (/home/ccuser/node_modules/babylon/lib/index.js:7305:37)
at File.parse (/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:517:15)
at File.parseCode (/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:602:20)
at /home/ccuser/node_modules/babel-core/lib/transformation/pipeline.js:49:12
at File.wrap (/home/ccuser/node_modules/babel-core/lib/transformation/file/index.js:564:16)
at Pipeline.transform (/home/ccuser/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
at Object.transformFileSync (/home/ccuser/node_modules/babel-core/lib/api/node.js:152:10)
at compile (/home/ccuser/node_modules/babel-register/lib/node.js:129:20)
at loader (/home/ccuser/node_modules/babel-register/lib/node.js:158:14)
at Object.require.extensions.(anonymous function) [as .js] (/home/ccuser/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (test.js:2:17)
at Module._compile (module.js:571:32)
at loader (/home/ccuser/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ccuser/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at /home/ccuser/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/home/ccuser/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/home/ccuser/node_modules/mocha/lib/mocha.js:469:10)
at Object. (/home/ccuser/node_modules/mocha/bin/_mocha:404:18)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3

``` It's been a month since I try to get over this exercise. I even send this error as a bug repost, but haven't got any reply. Hopefully, I can get help here. Screenshot is attached. Code:
let friend =  friends[2];

return (
  <div>
    <h1>{friend.title}</h1>        
    <img src={friend.src} />
  </div>
);


#2

look at line 1, you have <> before your import, that might cause trouble. Suggestion: remove the <> Otherwise, could you copy paste your full code to the forum so i can actually run it? As you see, the error might not always be where you expect it :wink:


#3

That was it! Thank you!


#4

the error message might look terrifying, but it can contain useful information:

SyntaxError: /home/ccuser/workspace/react-101-react-components-advanced-jsx-render-function-calculations/app.js: Unexpected token (1:1)

it says that in our app.js on line 1, column 1 (so first character on first line) is unexpected. Hope this helps you in the future as well :slight_smile:


#5

It looks terrifying indeed! But thank you for noticing that detail. I will pay attention next time.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.