React & TypeScript/React
[React] super(props);
yoonjong Park
2021. 2. 16. 15:47
보통 아래와 같은 구조로 리액트 Component 구조를 갖는다.
class App extends React.Component {
constructor() {
super();
...
}
render() {
return ();
}
}
super 는 상위 객체의 Method를 가져오는 것이다. 위에서 super();는 React Component에 object 와 Method를 전달하기 위한 것이다.
super(props), constructor(props)를 선언할 경우도 상위 컴포넌트에 object를 전달해주는 성격이 된다.
참조:
min9nim.github.io/2018/12/super-props/
velog.io/@hytenic/Javascript-javascript-OOP-Class-Super
velog.io/@tonyk0901/TIL-16-React-superprops-%EC%97%90-%EB%8C%80%ED%95%B4%EC%84%9C