#3.5 Forms

SilverAsh·2023년 10월 16일
0

React

목록 보기
2/16
post-thumbnail
import { useState } from "react"

function App() {
    const [value, setValue] = useState("");
    const onChange = (event: React.FormEvent<HTMLInputElement>) => {
        const { currentTarget: { value } } = event;
        setValue(value);
    }

    const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
        event.preventDefault();
        console.log('hello', value)
    }
    return <div>
        <form onSubmit={onSubmit} action="">
            <input value={value}
                onChange={onChange} placeholder='username' type="text" /><button>Log in</button>
        </form>
    </div>
}
profile
Frontend developer이자

0개의 댓글