Check out example codes for "javascript set css calss". It will help you in understanding the concepts better.

Code Example 1

document.getElementById("myElementID").classList.add('myClassName');
document.getElementById("myElementID").classList.remove('myClassName');

Learn ReactJs, React Native from akashmittal.com