So I'm trying to render an input tag conditionally so that is why I'm using a function instead of just putting it all into a return statement. The issue I'm encountering is whenever I type a single word into an input tag it looses focus and I have to click it again to re-gain focus. My code is like this:
function App() {
function InputTag() {
if (someCondition) {
return (
<input onChange={(e) => setState(e.target.value)} value={State} />
)
} else {
return (
<input disabled value={State} />
)
}
}
return (
<div>
<InputTag />
</div>
)
}
After some de-bugging I've found that this issue occurs when I'm using a function to return an input tag but in my case I have to use a function to return the input tag.
You can experience this issue at : https://codesandbox.io/s/xenodochial-bassi-3gmyk