Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Line 17:36: 'state' is not defined no-undef

here is my code and I cannot find where the problem is

import React, {Component} from "react";

export default class Product extends Component{

state = {
    id: this.props.product.id,
    productName: this.props.product.productName,
    price: this.props.product.price,
}
render(){
    return<div className="col-lg-g">
        <div className="card m-2">
            <div className="card-body">
                <div className="text-muted"># {this.props.id}</div>
                <h5 className="p-5 border-top">{this.props.productName}</h5>
                <div>$ {this.props.price}</div>
                //{console.log(state)}
            </div>
        </div>
        </div>
}

}

it shows Line 17:36: 'state' is not defined no-undef whenever I run the code

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

That's a class, when you write state = ... , that's an instance property, hence you access it with this.state.

about 4 years ago · Juan Pablo Isaza Report

0

ok i did console.log(state) but i should have used console.log(this.state)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!