0
UserNameChangeHandler = (event) => {
    this.setState({ username: event.target.value });
  };
  render() {
    return (
      <div className="App">
        <UserInput
          input={this.UserNameChangeHandler}
          currentName={this.state.username}
        />
        <UserOutput username={this.state.username} />
      </div>
    );
  }
}

here this keyword works fine with arrow function but the render() method also works fine with "this" keyword although its a normal method,

Shiladitya
  • 11,650
  • 15
  • 23
  • 35
  • value of `this` depends on how a function/method is called. In the case of React, `render()` method is called on an instance of a component. As a result, `this` inside the `render` method refers to the instance of your component on which this method is called. – Yousaf Sep 17 '21 at 04:54

0 Answers0