Check out example codes for "how to detect device javascirpt". It will help you in understanding the concepts better.

Code Example 1

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 // some code..
}

Learn ReactJs, React Native from akashmittal.com