If you came accross this error
ArgumentException: GetComponent requires that the requested component 'Image' derives from MonoBehaviour or Component or is an interface.
Use “using UnityEngine.UI” instead of “using UnityEngine.UIElements”
It had solve the issue for me