🐛 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:
Cristhian Zanforlin Lousa 2023-07-22 09:05:04 -03:00
commit 7d91c14481

View file

@ -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;
});