Check out example codes for "unity adding component to another gameobject". It will help you in understanding the concepts better.
Code Example 1
//referencing a gameobject
public GameObject exampleObject;
//===============================================================>
private Rigidbody rb; //example of a component
public void Awake() {
// adding a Rigidbody component to exampleObject
rb = exampleObject.AddComponent<Rigidbody>();
// referencing an existing Rigidbody component in exampleObject
rb = exampleObject.GetComponent<Rigidbody>();
}
Learn ReactJs, React Native from akashmittal.com