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

Code Example 1

var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);

Learn ReactJs, React Native from akashmittal.com