I'm stumped on this.
I have a controlled input (I'm using Material-UI TextField and Autocomplete).
I'm happy for the component to control its own value, except I want to be able to clear the input.
How would I do that?
function App() {
const handleClick = useCallback(() => {
//Do what?
}, []);
return (
<div className="App">
<TextField label="I'm a controlled input" />
<button onClick={handleClick}> Click to clear</button>
</div>
);
}
The reason I don't want to implement the state of this myself, is because the autocomplete + textfield is quite complex, I figure there must be a simpler solution.
Is there a way I could mimik a keyboard event to clear the textfield for example?