fix(web): satisfy React hook lint rules
This commit is contained in:
1 parent
bb68be14fa
commit
a4215f86fb
8 files changed
+374
-256
No files matched your search
@@ -1,20 +1,30 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { setAuthUserId, useAuthUserId } from '../config';
|
||||
|
||||
export default function DevAuthSwitcher() {
|
||||
const authUserId = useAuthUserId();
|
||||
const queryClient = useQueryClient();
|
||||
const [inputValue, setInputValue] = useState(authUserId ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(authUserId ?? '');
|
||||
}, [authUserId]);
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<DevAuthSwitcherForm
|
||||
key={authUserId ?? 'no-auth-user'}
|
||||
authUserId={authUserId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function DevAuthSwitcherForm({
|
||||
authUserId,
|
||||
}: {
|
||||
authUserId: string | null;
|
||||
}) {
|
||||
const queryClient = useQueryClient();
|
||||
const [inputValue, setInputValue] = useState(authUserId ?? '');
|
||||
|
||||
function updateAuthUserId(nextValue: string | null) {
|
||||
setAuthUserId(nextValue);
|
||||
void queryClient.invalidateQueries();
|
||||
|
||||
Reference in new issue
Block a user