Is usage of binding neccsary

Tell us what’s happening:
when i try this exercise in my react app(the code is in vs code not in fcc)
when i use bind method as shown below
this.handleClick = this.handleClick.bind(this);
the following errors come
“message”: “Unexpected token. A constructor, method, accessor, or property was expected.”,
“message”: “’;’ expected.”,
“message”: “Declaration or statement expected.”
it gives an error ,but when its removed it works fine ?should i need to worry about or just ignore
Your code so far

import React, { Component } from 'react';

class Xtreme extends Component {
    constructor(props) {
    this.state = {
        name: 'freeCodeCamp'
    //this.handleClick = this.handleClick.bind(this);
    handleClick =() => {
        name:'freecodecamp rocks'
  const name =;
    return (
    <div className="Xtreme">
        <p>{} again</p> 
        <button onClick={this.handleClick}>change me</button>
export default Xtreme;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Set State with this.setState

Function binding should go inside the constructor

1 Like

okay it works but do we really need it

You don’t need it, just remove the line and it will work because you’re using so-called class field in property = someValue; format, assigning arrow function to your handler.

1 Like