Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: useEffect warning fixes #1514

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const App = (props) => {
useEffect(() => {
updateDocumentTitle('Image Builder | Red Hat Insights');
hideGlobalFilter();
}, []);
}, [hideGlobalFilter, updateDocumentTitle]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

return (
<React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ export const AWSSourcesSelect = ({
useEffect(() => {
if (isFetchingDetails || !isSuccessDetails) return;
change('aws-associated-account-id', sourceDetails?.aws?.account_id);
}, [isFetchingDetails, isSuccessDetails]);
}, [
isFetchingDetails,
isSuccessDetails,
change,
sourceDetails?.aws?.account_id,
]);

const onFormChange = ({ values }) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ActivationKeys = ({ label, isRequired, ...props }) => {
change('subscription-server-url', 'subscription.rhsm.stage.redhat.com');
change('subscription-base-url', 'https://cdn.stage.redhat.com/');
}
}, []);
}, [isProd, change]);

const setActivationKey = (_, selection) => {
selectActivationKey(selection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ const AzureSourcesSelect = ({ label, isRequired, className, ...props }) => {
if (isFetchingDetails || !isSuccessDetails) return;
change('azure-tenant-id', sourceDetails?.azure?.tenant_id);
change('azure-subscription-id', sourceDetails?.azure?.subscription_id);
}, [isFetchingDetails, isSuccessDetails]);
}, [
isFetchingDetails,
isSuccessDetails,
sourceDetails?.azure?.subscription_id,
sourceDetails?.azure?.tenant_id,
change,
]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

const onFormChange = ({ values }) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const FileSystemConfigButtons = ({ handleNext, handlePrev, nextStep }) => {
);
const [nextHasBeenClicked, setNextHasBeenClicked] = useState(false);
const prefetchArchitectures = imageBuilderApi.usePrefetch('getArchitectures');
const errors = getState()?.errors?.['file-system-configuration'];

useEffect(() => {
const errors = getState()?.errors?.['file-system-configuration'];
errors ? setHasErrors(true) : setHasErrors(false);

if (!errors) {
setNextHasBeenClicked(false);
change('file-system-config-show-errors', false);
}
});
}, [errors, change]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

const handleClick = () => {
if (!hasErrors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const FileSystemConfiguration = ({ ...props }) => {
setItemOrder(newRows.map((row) => row.id));
change('file-system-config-radio', 'manual');
}
}, [customizations, isSuccess]);
}, [customizations, isSuccess, change, hasCustomizations, rows]);

useEffect(() => {
const fsc = getState()?.values?.['file-system-configuration'];
Expand All @@ -123,7 +123,7 @@ const FileSystemConfiguration = ({ ...props }) => {
});
setRows(newRows);
setItemOrder(newOrder);
}, []);
}, [getState]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

const showErrors = () =>
getState()?.values?.['file-system-config-show-errors'];
Expand All @@ -144,7 +144,7 @@ const FileSystemConfiguration = ({ ...props }) => {
return null;
})
);
}, [rows, itemOrder]);
}, [rows, itemOrder, change, input.name]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

const addRow = () => {
const id = uuidv4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
return;
}
}
}, []);
}, [props.mountpoint]);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
let suf = suffix;
Expand All @@ -50,7 +50,7 @@
}

props.onChange(path.normalize(mp));
}, [prefix, suffix]);

Check warning on line 53 in src/Components/CreateImageWizard/formComponents/MountPoint.js

View workflow job for this annotation

GitHub Actions / tests (16.x)

React Hook useEffect has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useEffect call and refer to those specific props inside useEffect

Check warning on line 53 in src/Components/CreateImageWizard/formComponents/MountPoint.js

View workflow job for this annotation

GitHub Actions / tests (18.x)

React Hook useEffect has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useEffect call and refer to those specific props inside useEffect

const onToggle = (isOpen) => {
setIsOpen(isOpen);
Expand Down
Loading