В React для обработки изменений переменных мы делаем:
handleChangeRound = (round) => {
this.setState({round: round});
}
updateLoading = (isLoading) => {
this.setState({isLoading: isLoading});
}
Есть ли способ записать
this.setState({round: round});
this.setState({isLoading: isLoading});
как
this.updateState(round);
this.updateState(isLoading);
, учитываяпеременные round
и isLoading
существуют в состоянии и соответствуют имени переменной, чтобы избежать избыточности variable: variable
?
PS: вдохновлен:
console.log({x: x, y: y});
// output:
// {x: 10, y:20}
canзаписываться как
console.log({x,y});
// output:
// {x: 10, y:20}