함수형 컴포넌트(functional Component)가 나온 이유는?

클래스형 컴포넌트의 치명적인 단점

  1. this 를 잃어버리는 경우
class App {

constructor(state) {
this.state = state;
}

showState() {
console.log(this.state);
}
}

const app = new App('num');

app.showState(); // num

const showState = app.showState;
showState(); // 에러
  1. this 가 가리키는 대상이 바뀌는 경우