Check out example codes for "how do I attach a player with a navMeshAgent". It will help you in understanding the concepts better.

Code Example 1

public var player : Transform;    function Awake () { player = GameObject.FindGameObjectWithTag ("Player").transform; nav = GetComponent (UnityEngine.AI.NavMeshAgent); }  function Update() {     var distance = Vector3.Distance(player.position, transform.position);              if(distance <= 30) {                        nav.enabled = true;            nav.SetDestination (player.position);         }                 else  {            this.nav.enabled = false;                  } }

Learn ReactJs, React Native from akashmittal.com