I have options array for month and I am using it in useEffect but getting warning for deps.
Kindly guide how to use useMemo.
I am getting warning as given below:
The 'options' array makes the dependencies of useEffect Hook (at line 83) change on every render. To fix this, wrap the initialization of 'options' in its own useMemo Hook react-hooks/exhaustive-deps
const options = [];
useEffect(() => {
if (financialMonth) {
options.forEach((item) => {
if (Number(item.value) === Number(financialMonth)) {
setMonthDefault(item.text);
}
});
if (financialMonth.length === 0) setMonthDefault("April");
}
}, [financialMonth, options]);