1

I created a project with create-react-app and I'm trying to load an image but I keep getting the same parsing error.

Here is the code:

  1 import React, { Component } from 'react'
  2 import profile from './profile.png'
  3 
  4 class Jumbotron extends Component {
  5     render() {
  6         return (
  7             <div className="container">
  8                 <JumbotronName />
  9                 <JumbotronImg />
 10             </div>
 11         )
 12     }
 13 }
 14 
 15 const JumbotronName = () => {
 16     return (
 17         <div className="container">
 18             <h1>Temp</h1>
 19         </div>
 20     )
 21 }
 22 
 23 const JumbotronImg = () => {
 24     return (
 25         <div className="container">
 26             <img src{profile} alt="Profile" />
 27         </div>
 28     )
 29 }
 30 
 31 export default Jumbotron

Both files (Jumbotron.js and the image) are in the src folder of the create-react-app.

When I run with npm start, i get this parsing error

./src/Jumbotron.js
  Line 26:22:  Parsing error: Unexpected token, expected "..."

  24 |     return (
  25 |         <div className="container">
> 26 |             <img src{profile} alt="Profile" />
     |                      ^
  27 |         </div>
  28 |     )
  29 | }

Any ideas?

EDIT: if I put '...' before profile in line 26 (ex src{...profile}), it will compile but the image will not load

1
  • 1
    You're missing an equals sign: <img src={profile}. Flagged as typo. Commented Nov 8, 2019 at 18:21

1 Answer 1

3

you need to write equation sign like this

 <img src={profile} alt="Profile" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.