Home > database >  Line 7:9: Expected an assignment or function call and instead saw an expression no-unused-expression
Line 7:9: Expected an assignment or function call and instead saw an expression no-unused-expression

Time:03-26

import React from 'react'
import "./main.css";

function MainContent(){

        <div className="card">

            <div className="card_img">
                <img src="./images/iphone_13_pro_max.png" />
            </div>

            <div className="card_header">
                <h2>"I Phone 13 Pro Max"</h2>
                <p>"Release date: 14th September 2021"</p>
                <p className='starPatter'>"4.5/5"</p>
            <div className='btn'>More Details</div>

            </div>

        </div>

My Code is this and when i run the code it gives me below error

Line 7:9: Expected an assignment or function call and instead saw an expression no-unused-expressions

I tried what I know for this but it not solved

CodePudding user response:

Wrap your jsx inside return statement

return (
   <div className="card">
   ...
   </div>);

CodePudding user response:

I think the problem is that you put your jsx in the function `MainContent without returning anything.

To fix this do:

function MainContent() {
  return (
    <put all the jsx here>
  )
}
  • Related