Sep 8, 2018 · 1 min read
Why not pass in the isLoading to the loader, the error to the Error and the results length to the NoResults and let them handle wether what they return as contextually it is their responsibility? If the Error component receives an information that there is no Error it just returns null. You don’t need any switches and scattered logic and the Error handles error logic, Loading handles loading logic etc. and your main component is a lot cleaner and elegant