Skip to content

Commit

Permalink
refactor: optimize retry and keep user functions
Browse files Browse the repository at this point in the history
Refactor the `onRetry` function to use `useCallback` for better 
performance and prevent unnecessary re-renders. 
Introduce a new 
`onKeepCurrentUser` function that removes BFF error parameters 
from the URL and calls `onRetry`.
  • Loading branch information
snaerth committed Dec 18, 2024
1 parent 487baae commit 65f8cb0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libs/react-spa/bff/src/lib/BffProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ export const BffProvider = ({
setSessionExpiredScreen(true)
}, [])

const onRetry = () => {
const onRetry = useCallback(() => {
window.location.href = applicationBasePath
}
}, [applicationBasePath])

const onKeepCurrentUser = useCallback(() => {
BffError.removeBffErrorParamsFromURL()
onRetry()
}, [onRetry])

const renderContent = () => {
if (mockedInitialState) {
Expand All @@ -255,7 +260,7 @@ export const BffProvider = ({
return (
<BffDoubleSessionModal
onSwitchUser={switchUser}
onKeepCurrentUser={onRetry}
onKeepCurrentUser={onKeepCurrentUser}
/>
)
}
Expand Down

0 comments on commit 65f8cb0

Please sign in to comment.