Skip to content

Commit b7719fe

Browse files
Fix ESLint missing React hook dependencies
1 parent 4b087d3 commit b7719fe

File tree

11 files changed

+17
-28
lines changed

11 files changed

+17
-28
lines changed

src/components/content-presentation/table/Table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const TableComponent = forwardRef<HTMLTableElement, TableProps>((props, forwarde
4545
responsive,
4646
setHeadings,
4747
};
48-
}, [responsive, headings, setHeadings]);
48+
}, [firstCellIsHeader, headings, responsive, setHeadings]);
4949

5050
return (
5151
<TableContext.Provider value={contextValue}>

src/components/content-presentation/table/components/TableRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const TableRow: FC<ComponentPropsWithoutRef<'tr'>> = ({ children, classNa
1919
if (responsive && section === TableSection.HEAD) {
2020
setHeadings(getHeadingsFromChildren(children));
2121
}
22-
}, [responsive, section, children]);
22+
}, [children, responsive, section, setHeadings]);
2323

2424
const tableCells = Children.map(children, (child, index) => {
2525
return section === TableSection.BODY && isTableCell(child)

src/components/form-elements/checkboxes/components/Item.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export const CheckboxesItem = forwardRef<HTMLInputElement, CheckboxesItemProps>(
4242
const { getBoxId, name, leaseReference, unleaseReference } =
4343
useContext<ICheckboxesContext>(CheckboxesContext);
4444

45-
const [boxReference] = useState<string>(leaseReference());
46-
const inputID = id || getBoxId(boxReference);
45+
const [checkboxReference] = useState<string>(leaseReference());
46+
const inputID = id || getBoxId(checkboxReference);
4747
const shouldShowConditional = !!(checked || defaultChecked);
4848

4949
const { className: labelClassName, ...restLabelProps } = labelProps || {};
5050
const { className: hintClassName, ...restHintProps } = hintProps || {};
5151
const { className: conditionalClassName, ...restConditionalProps } = conditionalProps || {};
5252

53-
useEffect(() => () => unleaseReference(boxReference), []);
53+
useEffect(() => () => unleaseReference(checkboxReference));
5454

5555
const inputProps: HTMLAttributesWithData<HTMLInputElement> = rest;
5656

src/components/form-elements/date-input/DateInput.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import classNames from 'classnames';
22
import {
33
createRef,
44
forwardRef,
5-
useEffect,
65
useState,
76
type ChangeEvent,
87
type ComponentPropsWithoutRef,
@@ -50,16 +49,6 @@ const DateInputComponent = forwardRef<HTMLDivElement, DateInputProps>(
5049
year: value?.year ?? '',
5150
});
5251

53-
useEffect(() => {
54-
const newState = { ...internalDate };
55-
const { day, month, year } = value ?? {};
56-
if (day && day !== internalDate.day) newState.day = day;
57-
if (month && month !== internalDate.month) newState.month = month;
58-
if (year && year !== internalDate.year) newState.year = year;
59-
60-
return setInternalDate(newState);
61-
}, [value]);
62-
6352
const handleChange = (inputType: InputType, event: ChangeEvent<HTMLInputElement>): void => {
6453
event.stopPropagation();
6554

src/components/form-elements/radios/components/Item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export const RadiosItem = forwardRef<HTMLInputElement, RadiosItemProps>((props,
4848

4949
useEffect(() => {
5050
if (defaultChecked) setSelected(radioReference);
51-
}, []);
51+
}, [defaultChecked, setSelected, radioReference]);
5252

5353
useEffect(() => {
5454
if (checked) setSelected(radioReference);
55-
}, [checked]);
55+
}, [checked, setSelected, radioReference]);
5656

5757
return (
5858
<>

src/components/navigation/header/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const HeaderComponent = forwardRef<HTMLElement, HeaderProps>((props, forwardedRe
106106
setServiceProps,
107107
setOrganisationProps,
108108
};
109-
}, [logoProps, serviceProps, organisationProps]);
109+
}, [logoProps, serviceProps, organisationProps, menuOpen]);
110110

111111
const items = Children.toArray(children);
112112
const childLogo = items.find((child) => childIsOfComponentType(child, Logo));

src/components/navigation/header/components/Logo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const Logo: FC<LogoProps> = (logo) => {
1414

1515
setLogoProps(logo);
1616
return () => setLogoProps(undefined);
17-
}, [logo]);
17+
}, [logo, setLogoProps]);
1818

1919
const { alt = 'NHS' } = logo;
2020

src/components/navigation/header/components/Navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Navigation: FC<NavigationProps> = ({
2626

2727
setMenuOpen(open);
2828
return () => setMenuOpen(false);
29-
}, [open]);
29+
}, [open, setMenuOpen]);
3030

3131
return (
3232
<nav

src/components/utils/FormGroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ export const FormGroup = <T extends BaseFormElementRenderProps>(
103103
useEffect(() => {
104104
passError(elementID, disableErrorFromComponents ? false : Boolean(error));
105105
return () => passError(elementID, false);
106-
}, [elementID, error]);
106+
}, [disableErrorFromComponents, elementID, error, passError]);
107107

108108
useEffect(() => {
109109
registerComponent(elementID);
110110
return () => registerComponent(elementID, true);
111-
}, []);
111+
}, [elementID, registerComponent]);
112112

113113
return (
114114
<div

src/util/hooks/UseDevWarning.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const useDevWarning = (warning: string, condition: ConditionFn = () => tr
99
// eslint-disable-next-line no-console
1010
console.warn(warning);
1111
}
12-
}, [warning]);
12+
}, [warning, condition]);
1313
};

0 commit comments

Comments
 (0)