Streamlined Validity Checks for Components

If a component is invalid, cmp.get() returns null. Previously, the framework returned an InvalidComponent error. The new behavior is more typical of standard JavaScript behavior and reduces framework memory usage.

If you call cmp.set() on an invalid component, nothing happens and no error occurs. It’s essentially a no op.

The cmp.isValid() call returns false for an invalid component.

You don’t need a cmp.isValid() check in the callback in a client-side controller when you reference the component associated with the client-side controller. The framework automatically checks that the component is valid. Similarly, you don’t need a cmp.isValid() check during event handling or in a framework lifecycle hook, such as the init event.

If you reference a component in asynchronous code, such as setTimeout() or setInterval(), or when you use Promises, a cmp.isValid() call checks that the component is still valid before processing the results of the asynchronous request. In many scenarios, the cmp.isValid() call isn’t necessary because a null check on a value retrieved from cmp.get() is sufficient. The main reason to call cmp.isValid() is if you’re making multiple calls against the component and you want to avoid a null check for each result.