How to change Dom document methods to REACT JS

How to convert or replace the below code into a react component code :

var pages = document.getElementsByClassName('page');
  for(var i = 0; i < pages.length; i++)
    {
      var page = pages[i];
      if (i % 2 === 0)
        {
          page.style.zIndex = (pages.length - i);
        }
    }


I have tried using many different methods and codes but it didn't worked.

If anyone could please help with the code.