fix(client-config): set isLoaded to false on API status update (#12371)
Attempt at #12289 (edit Félix: removed fix keyword since I don't think it fixes it) --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -1,21 +1,30 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { CaptchaProviderScriptLoaderEffect } from '@/captcha/components/CaptchaProviderScriptLoaderEffect';
|
||||
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
export const CaptchaProvider = ({ children }: React.PropsWithChildren) => {
|
||||
const location = useLocation();
|
||||
export const CaptchaProvider = React.memo(
|
||||
({ children }: React.PropsWithChildren) => {
|
||||
const location = useLocation();
|
||||
|
||||
if (!isCaptchaRequiredForPath(location.pathname)) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
const isCaptchaRequired = useMemo(
|
||||
() => isCaptchaRequiredForPath(location.pathname),
|
||||
[location.pathname],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div id="captcha-widget" data-size="invisible"></div>
|
||||
<CaptchaProviderScriptLoaderEffect />
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
{isCaptchaRequired && (
|
||||
<>
|
||||
<div id="captcha-widget" data-size="invisible"></div>
|
||||
<CaptchaProviderScriptLoaderEffect />
|
||||
</>
|
||||
)}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
CaptchaProvider.displayName = 'CaptchaProvider';
|
||||
|
||||
Reference in New Issue
Block a user