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>
  );
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #reset #input #react
ADD COMMENT
Topic
Name
4+4 =