Код: Выделить всё
const validateHeight= async () => {
const {currentFormData} = cloneDeep(state);
let validHeight;
//heightValidationLogic here, also includes API calls
if(validHeight){
return [true, max_height];
}
else {
return [false, 0];
}
const peculiarFunction = async () => { //This is the main function
let isvalidHeight = true;
let maxHeight = 0;
const {currentFormData} = cloneDeep(state);
if(currentFormData.map){ //checks if the map property is true
setState({...state, isLoading:'hasMap'})
[isValidHeight,maxHeight] = await validateHeight(); //Here, the other function is called
//Other height based logic
setState({...state, isLoading:''})
}
//Code to continue with form submission or show to error for invalid height
};
Код: Выделить всё
catch
Код: Выделить всё
catch
Код: Выделить всё
catch
Я понимаю, что у меня есть альтернатива возврата ответа в качестве объекта и буду двигаться вперед с ним, но я хочу понять это странное поведение и найти ответ для него.
Подробнее здесь: https://stackoverflow.com/questions/796 ... -is-even-c