Observe how all our logic got simpler by extracting the block to another component. See also that we are using again the approach of the IFs with the return. This approach is also known as Early return. When we use Early return, our logics tend to be simpler, since the next validation does not have to worry about the previous one. Ex: To check if it is loading, I do not have to worry if an error has occurred or not, since this case has already been handled in the previous IF.
Read full article by Vinicius Dacal |