Check out example codes for "how to print in html". It will help you in understanding the concepts better.

Code Example 1

<p>put text here</p>

Code Example 2

window.print();

Code Example 3

console.log("print")
//or
alert("Print")

Code Example 4

<button onClick="window.print()">Print</button>

Learn ReactJs, React Native from akashmittal.com