Fixed performance issue due to setting state unnecessarily.