122
rated 0 times
[
129]
[
7]
/ answers: 1 / hits: 42706
/ 4 Years ago, tue, june 16, 2020, 12:00:00
I have a text input. If I click on a specific button in the page, I want to reset the value of the input. Here is my code:
const inputRef = useRef()
const handleClick= () => {
inputRef.current.value.reset();
return hello world
}
return (
<>
<input type=text ref={inputRef}/>
<button onClick={()=> handleClick}>delete all</button>
</>
)
It doesn't work. How to fix this?
More From » reactjs