본문 바로가기

REACT/해결방안

[React]ComponentDidMount() 에 Props 값이 제대로 안들어갈 때

Mobx 에서 정해준 기본값 0. 상위 컴포넌트에서 Geolocation API 로 props값 변경.

 

해당 컴포넌트에서 console.log(this.props) 했을 때는 변경된 props 값 출력이 되는데

 

this.props.mylat 을 출력하면 기본값인 0이 나온다.

 

해결방법 : ComponentDidMount() -> ComponentDidUpdate 로 바꾼다.