Skip to content

Commit 74a13aa

Browse files
authored
Merge pull request #97 from imaginer-dev/96-공용-input-모든-어트리뷰트-받을-수-있도록-수정
96 공용 input 모든 어트리뷰트 받을 수 있도록 수정
2 parents 42990ae + 6c9d46a commit 74a13aa

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/components/common/InputForm.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
interface Props {
1+
import { HTMLProps } from 'react';
2+
3+
interface Props extends HTMLProps<HTMLInputElement> {
24
title: string;
35
placeholder: string;
46
hint: string;
57
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
68
}
79

8-
const InputForm: React.FC<Props> = ({ title, placeholder, hint, onChange }) => {
10+
const InputForm: React.FC<Props> = ({ title, placeholder, hint, onChange, ...rest }) => {
911
return (
1012
<label className="form-control w-full max-w-xs">
1113
<div className="label">
1214
<span className="label-text">{title}</span>
1315
</div>
14-
<input
15-
type="text"
16-
placeholder={placeholder}
17-
className="input input-bordered w-full max-w-xs"
18-
onChange={onChange}
19-
/>
16+
<input placeholder={placeholder} className="input input-bordered w-full max-w-xs" onChange={onChange} {...rest} />
2017
<div className="label">
2118
<span className="label-text-alt">{hint}</span>
2219
</div>

src/pages/InputFormTest.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ function TestInputForm() {
77
return (
88
<div>
99
<InputForm title="이름" placeholder="이름을 입력하세요" hint="hint text" onChange={onChange} />
10+
<InputForm
11+
title={'패스워드'}
12+
placeholder={'패스워드를 입력하세요'}
13+
hint={'hit text'}
14+
onChange={onChange}
15+
type={'password'}
16+
/>
1017
</div>
1118
);
1219
}

0 commit comments

Comments
 (0)