Skip to content

Commit

Permalink
Memoize Config and useConfigErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
atomicgamedeveloper committed Feb 20, 2025
1 parent 33dd22f commit 6dacf9d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions client/src/route/config/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,29 @@ const useValidationResults = () => {

const useConfigErrors = (validationResults: {
[key: string]: ValidationType;
}) =>
Object.keys(window.env).some(
(key) => key !== undefined && validationResults[key]?.error !== undefined,
}) => {
return React.useMemo(() =>
Object.keys(window.env || {}).some(
(key) => key !== undefined && validationResults[key]?.error !== undefined
),
[validationResults]
);
};

const Config = (props: { role: string }) => {
const { validationResults, isLoading } = useValidationResults();
const configVerification =

const configVerification = React.useMemo(() =>
props.role === 'user'
? UserConfig(validationResults)

Check failure on line 128 in client/src/route/config/Config.tsx

View workflow job for this annotation

GitHub Actions / Test react website (ubuntu-latest)

React Hook React.useMemo has a missing dependency: 'props.role'. Either include it or remove the dependency array
: DeveloperConfig(validationResults);

: DeveloperConfig(validationResults),
[validationResults]
);

if (isLoading) {
return loadingComponent();
}

return configVerification;
};

Expand Down

0 comments on commit 6dacf9d

Please sign in to comment.