In a React app I get this warning on a few components in the useEffect function. I have seen other SO questions but still cant see a fix.
React Hook useEffect has a missing dependency: 'loadItems'. Either include it or remove the dependency array
import React, { useState, useEffect } from "react";
import Button from "./common/button";
import { splitArray } from "../utility/chunkify";
const BudgetTypesList = ({ types, onDelete, onEdit }) => {
const [items, setItems] = useState([]);
useEffect(() => {
loadItems();
}, [types]);
const loadItems = () => {
const size = Math.ceil(types.length / 2);
const chunks = splitArray(types, size);
setItems(chunks);
};
.... rest of code here