From c62a668b3f2a21c20aaf275c3a04cba49cfccb27 Mon Sep 17 00:00:00 2001 From: Juan Cazala Date: Fri, 29 Nov 2024 10:27:07 -0300 Subject: [PATCH] fix: config issues (#1041) --- .../SmartItemBasicView/SmartItemBasicView.tsx | 8 +++----- packages/@dcl/inspector/src/hooks/sdk/useHasComponent.ts | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/@dcl/inspector/src/components/EntityInspector/SmartItemBasicView/SmartItemBasicView.tsx b/packages/@dcl/inspector/src/components/EntityInspector/SmartItemBasicView/SmartItemBasicView.tsx index ce1a6f233..088f49b96 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/SmartItemBasicView/SmartItemBasicView.tsx +++ b/packages/@dcl/inspector/src/components/EntityInspector/SmartItemBasicView/SmartItemBasicView.tsx @@ -1,7 +1,6 @@ import React, { useCallback, useMemo } from 'react' import { BsFillLightningChargeFill as SmartItemIcon } from 'react-icons/bs' import { withSdk } from '../../../hoc/withSdk' -import { useHasComponent } from '../../../hooks/sdk/useHasComponent' import { ConfigComponent } from '../../../lib/sdk/components' import { Container } from '../../Container' import { NftView } from './NftView' @@ -17,7 +16,6 @@ import './SmartItemBasicView.css' const SmartItemBasicView = withSdk(({ sdk, entity }) => { const { Config } = sdk.components - const hasConfig = useHasComponent(entity, Config) const renderField = useCallback( (field: ConfigComponent['fields'][0], idx: number) => { @@ -52,12 +50,12 @@ const SmartItemBasicView = withSdk(({ sdk, entity }) => { ) }, []) - if (!hasConfig) return null - const config = useMemo(() => { - return Config.get(entity) + return Config.getOrNull(entity) }, [entity]) + if (!config) return null + return ( { } }) + useEffect(() => { + setHasComponent(component.has(entity)) + }, [entity, component]) + return hasComponent }