I am just curious as to whether it is bad (or better) practice to keep this.setState
on one line of code, especially if only one state variable is being changed.
this.setState({
fruits: { apples: newApples, bananas: newBananas }
});
vs
this.setState({fruits: { apples: newApples, bananas: newBananas }});
fruits
definition on one line? It's all about personal preferences and the guidelines of your team. If the code is equally readable in both formats (which is again subjective), it doesn't matter. – Sulthan May 3 '19 at 12:53