@asgardeo/react 0.22.2 → 0.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1318,19 +1318,22 @@ var FlowMetaProvider = ({
1318
1318
  children,
1319
1319
  enabled = true
1320
1320
  }) => {
1321
- const { baseUrl, applicationId, platform } = useAsgardeo_default();
1321
+ const { baseUrl, applicationId, platform, isInitialized } = useAsgardeo_default();
1322
1322
  const i18nContext = useI18n_default();
1323
1323
  const [meta, setMeta] = (0, import_react10.useState)(null);
1324
1324
  const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
1325
1325
  const [error, setError] = (0, import_react10.useState)(null);
1326
1326
  const [pendingLanguage, setPendingLanguage] = (0, import_react10.useState)(null);
1327
- const hasFetchedRef = (0, import_react10.useRef)(false);
1327
+ const lastFetchedRef = (0, import_react10.useRef)(null);
1328
1328
  const fetchFlowMeta = (0, import_react10.useCallback)(async () => {
1329
1329
  if (!enabled || platform !== import_browser10.Platform.AsgardeoV2) {
1330
1330
  setMeta(null);
1331
1331
  setIsLoading(false);
1332
1332
  return;
1333
1333
  }
1334
+ if (!isInitialized && !applicationId) {
1335
+ return;
1336
+ }
1334
1337
  setIsLoading(true);
1335
1338
  setError(null);
1336
1339
  try {
@@ -1345,7 +1348,7 @@ var FlowMetaProvider = ({
1345
1348
  } finally {
1346
1349
  setIsLoading(false);
1347
1350
  }
1348
- }, [enabled, platform, baseUrl, applicationId, i18nContext?.currentLanguage]);
1351
+ }, [enabled, platform, baseUrl, applicationId, isInitialized, i18nContext?.currentLanguage]);
1349
1352
  const switchLanguage = (0, import_react10.useCallback)(
1350
1353
  async (language) => {
1351
1354
  if (!enabled || platform !== import_browser10.Platform.AsgardeoV2) return;
@@ -1384,11 +1387,10 @@ var FlowMetaProvider = ({
1384
1387
  }
1385
1388
  }, [pendingLanguage, i18nContext?.setLanguage]);
1386
1389
  (0, import_react10.useEffect)(() => {
1387
- if (!hasFetchedRef.current) {
1388
- hasFetchedRef.current = true;
1389
- fetchFlowMeta();
1390
+ if (lastFetchedRef.current === fetchFlowMeta) {
1390
1391
  return;
1391
1392
  }
1393
+ lastFetchedRef.current = fetchFlowMeta;
1392
1394
  fetchFlowMeta();
1393
1395
  }, [fetchFlowMeta]);
1394
1396
  (0, import_react10.useEffect)(() => {