🐛 fix(inputListComponent): remove redundant useEffect that sets inputList value from props
🐛 fix(inputListComponent): fix cloning of inputList array in onChange event handler to prevent mutation of state
This commit is contained in:
parent
247755c118
commit
7d91c14481
1 changed files with 1 additions and 7 deletions
|
|
@ -13,12 +13,6 @@ export default function InputListComponent({
|
|||
}: InputListComponentType) {
|
||||
const [inputList, setInputList] = useState(value ?? [""]);
|
||||
|
||||
useEffect(() => {
|
||||
if (value) {
|
||||
setInputList(value);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
useEffect(() => {
|
||||
if (disabled) {
|
||||
setInputList([""]);
|
||||
|
|
@ -48,7 +42,7 @@ export default function InputListComponent({
|
|||
placeholder="Type something..."
|
||||
onChange={(e) => {
|
||||
setInputList((old) => {
|
||||
let newInputList = _.cloneDeep(old);
|
||||
let newInputList = _.cloneDeep(inputList);
|
||||
newInputList[idx] = e.target.value;
|
||||
return newInputList;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue