Recoil-sync was causing issues with Firefox, replacing it with a simpler mechanism to hydrate variables on page load --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
30 lines
897 B
TypeScript
30 lines
897 B
TypeScript
import { billingCheckoutSessionState } from '@/auth/states/billingCheckoutSessionState';
|
|
import { BILLING_CHECKOUT_SESSION_DEFAULT_VALUE } from '@/billing/constants/BillingCheckoutSessionDefaultValue';
|
|
import { useRecoilCallback } from 'recoil';
|
|
|
|
export const useBuildSearchParamsFromUrlSyncedStates = () => {
|
|
const buildSearchParamsFromUrlSyncedStates = useRecoilCallback(
|
|
({ snapshot }) =>
|
|
async () => {
|
|
const billingCheckoutSession = snapshot
|
|
.getLoadable(billingCheckoutSessionState)
|
|
.getValue();
|
|
|
|
const output = {
|
|
...(billingCheckoutSession !== BILLING_CHECKOUT_SESSION_DEFAULT_VALUE
|
|
? {
|
|
billingCheckoutSession: JSON.stringify(billingCheckoutSession),
|
|
}
|
|
: {}),
|
|
};
|
|
|
|
return output;
|
|
},
|
|
[],
|
|
);
|
|
|
|
return {
|
|
buildSearchParamsFromUrlSyncedStates,
|
|
};
|
|
};
|