I want to change state elements if condition is met. To make this I tried wrote a function where I have this condition and my new state when condition is met. But how can I