비동기 저장소에서 값을 가져 와서 State에 할당하려고합니다. this.state.CustNo 및 this.state.stUserAccountNo가 null 반환상태 반환되지 않음 - 기본 네이티브
constructor(props) {
super(props);
this.state = {
stAccntList: [],
stUserAccountNo: '',
stCustNo: '',
resp: '',
};
AsyncStorage.getItem('UserAccountNo').then((value) => {
if (value != '') {
accno = value;
this.setState({ stUserAccountNo: value });
// alert(this.state.stUserAccountNo);
}
}).done();
AsyncStorage.getItem('CustomerNo').then((value) => {
if (value != '') {
cusno = value;
this.setState({ stCustNo: value });
// alert(this.state.stUserAccountNo);
}
}).done();
}
componentWillMount() {
let restUrl = urls.URL + this.state.stCustNo + "/" + "accounts" + "/" + this.state.stUserAccountNo;
}
URL로 심어 액세스하는 동안 국가의 값은 정의되지 않은/널오고있다.
어디로 잘못 가고 있는지 알려주세요.
을
async-await
의 사용을 만들 수있는, 그것 componentWillMount이 실행되기 전에 데이터를 사용할 수 있는지 guranteed 없습니다. –어떻게 달성할까요? –
restWrl의 목적이 componentWillMount에 무엇인가에 따라 달라집니다. –