Home > Enterprise >  Unhandled Rejection (TypeError): _this2.setState is not a function
Unhandled Rejection (TypeError): _this2.setState is not a function

Time:05-23

I'm new using React and I'm having this error to use the search bottom in my application. this the error

This is my code

code

[enter image description here][3] I'm also new in stackoverflow, let me know if you need more information.

thank you.

CodePudding user response:

There are a couple of methods how to fix the issue:

  • use an arrow function instead:
search  = (terms) => {}
  • Bind this into your functions you intend to use this.search = this.search.bind(this); inside your App constructor() after this.state

Have a look for more details: React - How to fix this.setState is not a function error

  • Related