Understanding reactjs update cycle