Check out example codes for "alert without page refresh". It will help you in understanding the concepts better.

Code Example 1

// note that its the return false; that prevents the page refresh.
<button onclick="alert('Hello'); return false;">Click</button>

Learn ReactJs, React Native from akashmittal.com