반응에 상태지도 나 소품지도 아래 목록은 여기 내 tbody
태그 안에 무슨이다.데 문제가
시도 된 로깅 this.props.listingData
& 시도했습니다.
[{"location_id":1,"location":"HKG","description":"Hong Kong","update_by":null,"update_time":null,"create_by":null,"create_time":null,"rec_state":0},{"location_id":2,"location":"KUL","description":"Kuala Lumpur","update_by":null,"update_time":null,"create_by":null,"create_time":null,"rec_state":0}]
가 작동해야 하는가 : 여기 내가 사용하는 샘플 map
데이터
입니까? 내 getDefaultProps
:
getDefaultProps() {
return {
//value: 'default value' //called as this.props.value
listingData: [{"location_id":1,"location":"HKG","description":"Hong Kong","update_by":null,"update_time":null,"create_by":null,"create_time":null,"rec_state":0},{"location_id":2,"location":"KUL","description":"Kuala Lumpur","update_by":null,"update_time":null,"create_by":null,"create_time":null,"rec_state":0}]
};
}
이 시도하고 여전히 오류가 발생.
'this.props.listingData'는 언제 할당 되었습니까? 구성 요소가 값을 가지기 전에 렌더링되지 않았습니까? –
앱이 시작되면 데이터 목록이 표시되고 할당됩니다. 나는'componentWillMount()'시도와'componentDidMount()'도 작동하지만'undefined' 오류의 map을 얻습니다. –
더 방어적인 자세를 취하십시오 :'{this.props.listingData && this.props.listingData.map (...' –