Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reset input react

const App = () => {
  const [message, setMessage] = useState('');
  return (
    <div>
      <input
        type="text"
        value={message}
		onChange={(event) => {
          setMessage(event.target.value);
        }}/>

      <button 
		onClick={() => {
          alert('check')
          // clear input value
          setMessage('');
        }}>
          Clear field
      </button>
    </div>
  );
};
 
PREVIOUS NEXT
Tagged: #reset #input #react
ADD COMMENT
Topic
Name
2+2 =