Focus on the search input field whenever showSearch state is true
I have a problem trying to focus on the input field whenever a state showSearch state is true. I am using useRef and useEffect to achieve this. So, whenever showSearch flag changes, i run useEffect hook which checks if showSearch is true and if it is, then it focuses to the HTML element references using useRef. However, there is something wrong with it because it does not run.