How to use arrow function component with input and onChange event in React JS

1 Answer

0 votes
import React, { useState } from "react";

const AFunction = () => {
  const [words, setWords] = useState("Arrow Function");
  const handleChange = event => setWords(event.target.value);
  return (
    <div>
      <h1>{words}</h1>
      <input type="text" value={words} onChange={handleChange} />
    </div>
  );
};
export default AFunction;


/*
run:

Arrow Function

*/

 



answered Apr 26, 2020 by avibootz
edited Apr 26, 2020 by avibootz
...