Skip to content

Commit

Permalink
useMemo around determineStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
mickhansen committed Jun 19, 2024
1 parent cc7f43c commit 99694bd
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/components/SEBankIDSameDeviceButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PKCE, AuthorizeResponse } from '@criipto/auth-js';
import React, {useCallback, useContext, useEffect, useState} from 'react';
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import CriiptoVerifyContext from '../context';
import { getUserAgent } from '../device';

Expand Down Expand Up @@ -75,15 +75,11 @@ async function fetchComplete(completeUrl: string) {
}
export default function SEBankIDSameDeviceButton(props: Props) {
const {loginHint} = useContext(CriiptoVerifyContext);
const userAgent = getUserAgent(typeof navigator !== 'undefined' ? navigator.userAgent : props.userAgent);
const mobileOS = userAgent?.os.name === 'iOS' ? 'iOS' : userAgent?.os.name === 'Android' ? 'android' : null;
const iOSSafari = mobileOS === 'iOS' && userAgent?.browser.name?.includes('Safari') ? true : false;
const iOSWebKit = mobileOS === 'iOS' && userAgent?.browser.name?.includes('WebKit') ? true : false;

const strategy = determineStrategy(
typeof navigator !== 'undefined' ? navigator.userAgent : props.userAgent,
const rawUserAgent = typeof navigator !== 'undefined' ? navigator.userAgent : props.userAgent;
const strategy = useMemo(() => determineStrategy(
rawUserAgent,
loginHint
);
), [rawUserAgent, loginHint]);

const [href, setHref] = useState<null | string>();
const [links, setLinks] = useState<Links | null>(autoHydratedState?.links ?? null);
Expand Down

0 comments on commit 99694bd

Please sign in to comment.