-
I've never seen an error this weird, and have no idea how to get around it. I've got the following hook: import useSWR from 'swr';
import { Account as AccountAPI } from '@air/api';
import { Account as TAccount } from '@air/api/types';
import { ACCOUNT } from '@constants/swrKeys';
export const useAccount = () => {
const { data: account, error, mutate } = useSWR<TAccount | null>(ACCOUNT, AccountAPI.get);
return {
account,
error,
isLoading: !account && !error,
key: ACCOUNT,
mutateAccount: mutate,
};
}; Used in a page file like so: export default function SomePage() {
const { account } = useAccount();
return <></>
} The fetch under the hood of export default function SomePage() {
const [account, setAccount] = useState<TAccount | null>(null);
useEffect(() => {
AccountAPI.get().then(_account => setAccount(_account));
}, []);
return <></>
} What makes this even more baffling is that the SWR hook is evaluating instantly when using the dev server, but not when leveraging prod. Running a prod build locally (see 5s delay)Running with dev server (no delay) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This is indeed very weird, is it possible to create a minimal reproduction on https://codesandbox.io (it's not a production build, though)? I cannot reproduce this locally. Can you confirm that the Also which SWR version was it? If you are on the latest, |
Beta Was this translation helpful? Give feedback.
-
There is indeed an uncaught error within my fetcher 🤦🏽♂️ |
Beta Was this translation helpful? Give feedback.
There is indeed an uncaught error within my fetcher 🤦🏽♂️