replace vanilla js with reactjs