Converting JS to React