From cef90aa238c96cbc97f8a61811cbea7421142664 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 18 May 2021 10:34:16 +0200 Subject: [PATCH] fixed merge error --- src/groups/GroupsSection.tsx | 8 ++--- src/realm-settings/RealmSettingsSection.tsx | 2 +- .../UserFederationLdapSettings.tsx | 33 +++++++++---------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/groups/GroupsSection.tsx b/src/groups/GroupsSection.tsx index 6d4dea09d2..17fff9e2be 100644 --- a/src/groups/GroupsSection.tsx +++ b/src/groups/GroupsSection.tsx @@ -66,10 +66,10 @@ export const GroupsSection = () => { } return groups; } - return []; - }, - (groups: GroupRepresentation[]) => { - if (groups.length) setSubGroups(groups); + return []; + }, + (groups: GroupRepresentation[]) => { + if (groups.length) setSubGroups(groups); }, [id] ); diff --git a/src/realm-settings/RealmSettingsSection.tsx b/src/realm-settings/RealmSettingsSection.tsx index 8f7d3e7180..bdececb0ca 100644 --- a/src/realm-settings/RealmSettingsSection.tsx +++ b/src/realm-settings/RealmSettingsSection.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useHistory } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Controller, FormProvider, useForm } from "react-hook-form"; diff --git a/src/user-federation/UserFederationLdapSettings.tsx b/src/user-federation/UserFederationLdapSettings.tsx index 0c1211e34f..54ee85a7d4 100644 --- a/src/user-federation/UserFederationLdapSettings.tsx +++ b/src/user-federation/UserFederationLdapSettings.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import { ActionGroup, AlertVariant, @@ -26,7 +26,7 @@ import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresenta import { Controller, useForm } from "react-hook-form"; import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; -import { asyncStateFetch, useAdminClient } from "../context/auth/AdminClient"; +import { useAdminClient, useFetch } from "../context/auth/AdminClient"; import { useAlerts } from "../components/alert/Alerts"; import { useTranslation } from "react-i18next"; import { ViewHeader } from "../components/view-header/ViewHeader"; @@ -35,7 +35,6 @@ import { ScrollForm } from "../components/scroll-form/ScrollForm"; import { KeycloakTabs } from "../components/keycloak-tabs/KeycloakTabs"; import { LdapMapperList } from "./ldap/mappers/LdapMapperList"; -import { useErrorHandler } from "react-error-boundary"; type ldapComponentRepresentation = ComponentRepresentation & { config?: { @@ -179,24 +178,24 @@ export const UserFederationLdapSettings = () => { const history = useHistory(); const adminClient = useAdminClient(); const { realm } = useRealm(); - const errorHandler = useErrorHandler(); const { id } = useParams<{ id: string }>(); const { addAlert } = useAlerts(); - useEffect(() => { - if (id) { - return asyncStateFetch( - () => adminClient.components.findOne({ id }), - (fetchedComponent) => { - if (fetchedComponent) { - setupForm(fetchedComponent); - } - }, - errorHandler - ); - } - }, []); + useFetch( + async () => { + if (id) { + return await adminClient.components.findOne({ id }); + } + return undefined; + }, + (fetchedComponent) => { + if (fetchedComponent) { + setupForm(fetchedComponent); + } + }, + [] + ); const setupForm = (component: ComponentRepresentation) => { Object.entries(component).map((entry) => {