rewrite react code