I'm solving a problem regarding setting up a multi-line input after clicking on it. (in default is it single line) I have created a state that I set to true on the onFocus event (I set it to false on the onBlur event). The problem is that after clicking, I immediately lose focus of the input and have to click again. Is there any solution for this?
export default function App() {
const [focus, setFocus] = React.useState(false);
return (
<TextField
type="text"
value="lollec asda sd asd as das "
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
multiline={focus}
rows={3}
/>
);
}
Demo: https://codesandbox.io/s/hardcore-night-vhep1?file=/src/App.js