Untitled
unknown
javascript
10 months ago
931 B
16
Indexable
import { useState } from 'react';
import './App.css';
function StringExample() {
const [name, setName] = useState('');
const [message, setMessage] = useState('');
function handleSubmit(e) {
e.preventDefault();
alert(`이름: ${name}, 메시지: ${message}`);
setName('');
setMessage('');
}
return (
<>
<form onSubmit={handleSubmit}>
<input
type="text"
value={name}
// onChange={(e) => setName(e.target.value)}
/>
<p>입력한 이름: {name}</p>
<input
type="text"
value={message}
// onChange={(e) => setMessage(e.target.value)}
/>
<p>입력한 메시지: {message}</p>
<button type="submit">제출</button>
</form>
</>
);
}
function App() {
return (
<>
<StringExample />
</>
);
}
export default App;
Editor is loading...
Leave a Comment