Skip to content

Commit

Permalink
refactor: 중복 key 값 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
sikkzz committed Feb 16, 2025
1 parent 052a4f7 commit 1a53274
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/ReceiptEdit/ReceiptEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ const ReceiptEdit = () => {
setFocusState((prevState) => ({ ...prevState, [key]: false }));
};

const handleInputChange = (key: string, value: string) => {
const handleInputChange = (index: number, value: string) => {
setFormData((prevData) =>
prevData.map((item) => (item.key === key ? { ...item, value } : item)),
prevData.map((item, idx) => (idx === index ? { ...item, value } : item)),
);
};

Expand Down Expand Up @@ -133,10 +133,10 @@ const ReceiptEdit = () => {
<Input
placeholder={`${data.key} 입력`}
value={data.value}
onFocus={() => handleFocus(data.key)}
onBlur={() => handleBlur(data.key)}
isFocus={focusState[data.key] || false}
onChange={(e) => handleInputChange(data.key, e.target.value)}
onFocus={() => handleFocus(index.toString())}
onBlur={() => handleBlur(index.toString())}
isFocus={focusState[index.toString()] || false}
onChange={(e) => handleInputChange(index, e.target.value)}
/>
</div>
))}
Expand Down

0 comments on commit 1a53274

Please sign in to comment.