I have always seen Salesforce Aura Component developers using multiple checks before fetching data from component.find
method. It is because, it does return three types of results:
undefined
– when there are no items found on the DOM- Single component – when there are only one item found in the DOM
- Array of components – when there are more than an item found in the DOM