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

172
Views
App.js:69 Uncaught TypeError: Cannot read properties of undefined (reading 'setState')

Can anyone help me, I am getting this error "App.js:69 Uncaught TypeError: Cannot read properties of undefined (reading 'setState') at onInputChange (App.js:69:1)" Code Snippet

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

0

Few ways to go about this.

Since you're not using arrow function you need to bind your handlers

constructor() {
  ...code
  this.onInputChange = this.onInputChange.bind(this)
  this.onButtonSubmit = this.onInputChange.bind(this)
}

option 2 - switch your function to arrow function

onInputChange = (event) => {
  ...code
}

onButtonSubmit = () => {
  ...code
}

Here's a helpful post to help you understand why

https://www.freecodecamp.org/news/this-is-why-we-need-to-bind-event-handlers-in-class-components-in-react-f7ea1a6f93eb/

about 4 years ago · Juan Pablo Isaza Report

0

You can either change onInputChange method to use arrow function or you need to bind this for the onInputChange function.

Using arrow function:

onInputChange = (event) => {
  this.setState({ input: event.target.value });
};

Using bind:

<ImageLinkForm onInputChange={this.onInputChange.bind(this)} onButtonSubmit={this.onButtonSubmit.bind(this)} />
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!