I am having issues with typescript react in when try to define a value.
Here is the error:
Argument of type '{}' is not assignable to parameter of type 'SetStateAction<boolean[]>'. Type '{}' is not assignable to type '(prevState: boolean[]) => boolean[]'. Type '{}' provides no match for the signature '(prevState: boolean[]): boolean[]'.ts(2345)
Here is my following code:
const [addButtonFruits, setAddButtonFruits] = useState([true]);
useEffect(() => {
const initialAddButtonFruits = {};
fruitsArray.map((each) => (initialAddButtonFruits[each] = true));
setAddButtonFruits(initialAddButtonFruits);
}, []); // only executed for initial rendering