Check out example codes for "html canvas tutorial". It will help you in understanding the concepts better.

Code Example 1

<!-- Answer to: "html canvas tutorial" -->

<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>

<script>
// Get the element:
var canvas = document.getElementById("myCanvas");
// Create 2D object:
var ctx = canvas.getContext("2d");
// Change the colour to red (#ff0000):
ctx.fillStyle = "#FF0000";
// Make the position of the object (ctx) at (0, 0) and give
// it the height of 75px and the width of 150px:
ctx.fillRect(0,0,150,75);
</script>

<!-- For information, check the source in the corner below -->

Code Example 2

<canvas id="myCanvas" width="200" height="100"
style="border:1px solid 
#000000;">

</canvas>

Learn ReactJs, React Native from akashmittal.com