TypeError: Cannot read property ‘setState’ of undefined

state= {
users :[
{ name : ‘ram’ , salary :2000 },
{ name : ‘john’ , salary :3000}
]
}
updateUsers( ){
this.setState(
{
users :[
{ name : ‘smith’ , salary :12000 },
{ name : ‘lara’ , salary :3400}
]
}
)
}
<buttononClick={this.updateUsers}>Update Users</button>
But it is show me error :
TypeError: Cannot read property ‘setState’ of undefined
Solution :
Change update user as
updateUsers = () => {
this.setState(
{
users :[
{ name : ‘smith’ , salary :12000 },
{ name : ‘lara’ , salary :3400}
]
}
)
}

Notice: compact(): Undefined variable: limits in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Leave a Reply

Your email address will not be published. Required fields are marked *

− 6 = 3