LoginSignup
1
0

More than 1 year has passed since last update.

【TypeScript】useRefを使ってテキストフィールド実装

Last updated at Posted at 2021-10-16
import { useRef } from "react";

const sendInput = (inputValue: string | undefined) => {
  console.log(inputValue)

}

function App() {
  const inputRef = useRef<HTMLInputElement>(null);
  return (
    <div className="App">
      <input ref={inputRef} type="text" />
      <button onClick={()=>sendInput(inputRef.current?.value)}>送信</button>
    </div>
  );
}

export default App;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0