Check out example codes for "unity set material". It will help you in understanding the concepts better.

Code Example 1

gameObject.GetComponent<Renderer>().material = newMaterial;

Code Example 2

currentObject.GetComponent<Renderer>().material = materialToAssign;

Code Example 3

Renderer rend = GetComponent<Renderer>();
 if (rend != null){
     rend.material = newMaterialRef;
 }

Learn ReactJs, React Native from akashmittal.com