diff --git a/apps/web/src/components/common/input/InputList.tsx b/apps/web/src/components/common/input/InputList.tsx index f6247d5..b0964a5 100644 --- a/apps/web/src/components/common/input/InputList.tsx +++ b/apps/web/src/components/common/input/InputList.tsx @@ -1,22 +1,29 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Input, Button } from "antd"; import { DeleteOutlined } from "@ant-design/icons"; interface InputListProps { - initialValue?: string[]; + value?: string[]; onChange?: (value: string[]) => void; placeholder?: string; } const InputList: React.FC = ({ - initialValue, + value, onChange, placeholder = "请输入内容", }) => { // Internal state management with fallback to initial value or empty array - const [inputValues, setInputValues] = useState( - initialValue && initialValue.length > 0 ? initialValue : [""] - ); + const [inputValues, setInputValues] = useState([""]); + + // Update inputValues when value changes + useEffect(() => { + if (value && value.length > 0) { + setInputValues(value); + } else { + setInputValues([""]); + } + }, [value]); // Handle individual input value change const handleInputChange = (index: number, newValue: string) => {