Skip to content

Commit 6c80086

Browse files
committed
fix: try to fix preview env
for some reason the UI isn't updating in the preview env - I suspect this is because we haven't told SWR it needs to refresh and its refresh behavior is more liberal in development
1 parent cab9fd0 commit 6c80086

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/referrals/hooks.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ export function useReferrals () {
2626
const params = useSearchParams()
2727
const urlQueryEmail = params.get('email')
2828
const accountEmail = account?.toEmail()
29-
const [referrerEmail, setReferrerEmail] = useState<string>()
29+
const [referrerEmail, setReferrerEmailState] = useState<string>()
3030
const email = urlQueryEmail || accountEmail || referrerEmail
3131
const { data: refcodeResult, mutate: mutateRefcode, isLoading: refcodeIsLoading } = useSWR<RefcodeResult>(email && `${REFERRALS_SERVICE}/refcode/${encodeURIComponent(email)}`, fetcher)
32+
function setReferrerEmail(email: string){
33+
setReferrerEmailState(email)
34+
mutateRefcode()
35+
}
3236
const refcode = refcodeResult?.refcode
3337
const { data: referralsResult, isLoading: referralsAreLoading } = useSWR<ReferralsResult>(refcode && `${REFERRALS_SERVICE}/referrals/${refcode}`, fetcher)
3438
const referrals = referralsResult?.referrals

0 commit comments

Comments
 (0)