fix exhaustive-deps warnings for custom hooks
This commit is contained in:
parent
b615e6ccba
commit
33d5987269
@ -50,8 +50,8 @@ const ImageEditInput: FC<ImageEditInputProps> = (props: ImageEditInputProps) =>
|
||||
return './img/error.png';
|
||||
}
|
||||
},
|
||||
[value, setValid, isMounted, setMessage],
|
||||
'./img/loading.svg',
|
||||
[value],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -28,7 +28,7 @@ const TokenRow: FC<TokenRowProps> = (props: TokenRowProps) => {
|
||||
|
||||
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
||||
|
||||
const [guildSocketConfigs] = useOneTimeAsyncAction(async () => await guild.fetchSocketConfigs(), null, [guild]);
|
||||
const [guildSocketConfigs] = useOneTimeAsyncAction(async () => await guild.fetchSocketConfigs(), [guild], null);
|
||||
const iconSrc = useRecoilValueSoftImgSrc(
|
||||
guildResourceSoftImgSrcState({
|
||||
guildId: guild.id,
|
||||
|
@ -70,7 +70,7 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
||||
const [avatarInputMessage, setAvatarInputMessage] = useState<string | null>(null);
|
||||
const [avatarInputValid, setAvatarInputValid] = useState<boolean>(false);
|
||||
|
||||
const [exampleAvatarBuff, exampleAvatarBuffError] = useOneTimeAsyncAction(async () => await fs.readFile(exampleAvatarPath), null, [exampleAvatarPath]);
|
||||
const [exampleAvatarBuff, exampleAvatarBuffError] = useOneTimeAsyncAction(async () => await fs.readFile(exampleAvatarPath), [exampleAvatarPath], null);
|
||||
|
||||
useEffect(() => {
|
||||
if (exampleAvatarBuff) {
|
||||
@ -103,7 +103,7 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
||||
|
||||
setOverlay(null);
|
||||
return { result: newGuild, errorMessage: null };
|
||||
}, [displayName, avatarBuff, displayNameInputValid, avatarInputValid, setOverlay]);
|
||||
}, [guildsManager, validationErrorMessage, expired, displayName, avatarBuff, setCurrGuildId, setOverlay, addGuildData]);
|
||||
|
||||
const errorMessage = useMemo(() => {
|
||||
if (validationErrorMessage) return validationErrorMessage;
|
||||
@ -114,11 +114,22 @@ const AddGuildOverlay: FC<AddGuildOverlayProps> = (props: AddGuildOverlayProps)
|
||||
return (
|
||||
<Overlay childRootRef={rootRef}>
|
||||
<div ref={rootRef} className="content add-guild">
|
||||
<InvitePreview name={addGuildData.name} iconSrc={addGuildData.iconSrc} url={addGuildData.url} expiresFromNow={addGuildData.expires ? moment.duration(addGuildData.expires - Date.now(), 'ms') : null} />
|
||||
<InvitePreview
|
||||
name={addGuildData.name}
|
||||
iconSrc={addGuildData.iconSrc}
|
||||
url={addGuildData.url}
|
||||
expiresFromNow={addGuildData.expires ? moment.duration(addGuildData.expires - Date.now(), 'ms') : null}
|
||||
/>
|
||||
<div className="divider" />
|
||||
<div className="personalization">
|
||||
<div className="avatar">
|
||||
<ImageEditInput maxSize={Globals.MAX_AVATAR_SIZE} value={avatarBuff} setValue={setAvatarBuff} setValid={setAvatarInputValid} setMessage={setAvatarInputMessage} />
|
||||
<ImageEditInput
|
||||
maxSize={Globals.MAX_AVATAR_SIZE}
|
||||
value={avatarBuff}
|
||||
setValue={setAvatarBuff}
|
||||
setValid={setAvatarInputValid}
|
||||
setMessage={setAvatarInputMessage}
|
||||
/>
|
||||
</div>
|
||||
<div className="display-name">
|
||||
<TextInput
|
||||
|
@ -89,7 +89,7 @@ const ChannelOverlay: FC<ChannelOverlayProps> = (props: ChannelOverlayProps) =>
|
||||
setOverlay(null);
|
||||
return { result: null, errorMessage: null };
|
||||
},
|
||||
[guild, edited, validationErrorMessage, name, flavorText, setOverlay],
|
||||
[guild, edited, channel, validationErrorMessage, name, flavorText, setOverlay],
|
||||
{ start: channel ? 'Modify Channel' : 'Create Channel' },
|
||||
);
|
||||
|
||||
|
@ -99,7 +99,7 @@ const PersonalizeOverlay: FC<PersonalizeOverlayProps> = (props: PersonalizeOverl
|
||||
setOverlay(null);
|
||||
return { result: null, errorMessage: null };
|
||||
},
|
||||
[validationErrorMessage, displayName, savedDisplayName, avatarBuff, savedAvatarBuff, setOverlay],
|
||||
[validationErrorMessage, displayName, savedDisplayName, guild, avatarBuff, savedAvatarBuff, setOverlay],
|
||||
);
|
||||
|
||||
//if (saveFailed) return 'Unable to save personalization';
|
||||
|
@ -61,8 +61,8 @@ function useShake(ms: number): [shaking: boolean, doShake: () => void] {
|
||||
// runs an Async action one time (updates when deps changes)
|
||||
export function useOneTimeAsyncAction<T, V>(
|
||||
actionFunc: () => Promise<T>,
|
||||
initialValue: V,
|
||||
deps: DependencyList,
|
||||
initialValue: V,
|
||||
): [value: T | V, error: unknown | null] {
|
||||
const isMounted = useRef(false);
|
||||
|
||||
@ -241,8 +241,8 @@ export function useDownloadButton(
|
||||
|
||||
setText(textMapping.success);
|
||||
},
|
||||
// TODO: look into this warning
|
||||
[downloadName, fetchBuff, ...fetchBuffDeps, filePath, fileBuffer],
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[shaking, doShake, downloadName, fetchBuff, ...fetchBuffDeps, filePath, fileBuffer, textMapping.pendingFetch, textMapping.notReadyFetch, textMapping.errorFetch, textMapping.errorSave, textMapping.success],
|
||||
);
|
||||
|
||||
return [callable, text, shaking];
|
||||
|
@ -61,7 +61,7 @@ const GuildListContainer: FC = () => {
|
||||
} else {
|
||||
setOverlay(<AddGuildOverlay addGuildData={addGuildData} />);
|
||||
}
|
||||
}, []);
|
||||
}, [setOverlay]);
|
||||
|
||||
return (
|
||||
<div className="guild-list-container">
|
||||
|
@ -42,8 +42,8 @@ const AttachmentPreview: FC<AttachmentPreviewProps> = (props: AttachmentPreviewP
|
||||
return './img/file-improved.svg';
|
||||
}
|
||||
},
|
||||
'./img/loading.svg',
|
||||
[attachmentBuff],
|
||||
'./img/loading.svg',
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -30,13 +30,11 @@ import EnsuredFetchable from './fetchable-ensured';
|
||||
import { EventEmitter } from 'tsee';
|
||||
import { AutoVerifierChangesType } from './auto-verifier';
|
||||
import { IDQuery, PartialMessageListQuery } from './auto-verifier-with-args';
|
||||
import Util from './util';
|
||||
|
||||
/** the general guild class. This handles connecting a RAM, PersonalDB, and Socket guild together using fetchable-pair-verifiers and some manual caching to nicely update messages */
|
||||
export default class CombinedGuild
|
||||
extends EventEmitter<Connectable & Conflictable>
|
||||
implements AsyncGuaranteedFetchable, AsyncRequestable
|
||||
{
|
||||
implements AsyncGuaranteedFetchable, AsyncRequestable {
|
||||
private readonly ramGuild: RAMGuild;
|
||||
private readonly personalDBGuild: PersonalDBGuild;
|
||||
private readonly socketGuild: SocketGuild;
|
||||
|
Loading…
Reference in New Issue
Block a user