@@ -69,23 +69,19 @@ const UnitMenu = ({ containerId, displayName }: ContainerMenuProps) => {
6969const UnitInfo = ( ) => {
7070 const intl = useIntl ( ) ;
7171
72- const { setUnitId } = useLibraryContext ( ) ;
72+ const { libraryId , setUnitId } = useLibraryContext ( ) ;
7373 const { componentPickerMode } = useComponentPickerContext ( ) ;
7474 const {
7575 defaultTab, hiddenTabs, sidebarComponentInfo, sidebarTab, setSidebarTab,
7676 } = useSidebarContext ( ) ;
7777 const { insideUnit, navigateTo } = useLibraryRoutes ( ) ;
78- const { data : container } = useContainer ( unitId ) ;
7978
8079 const tab : UnitInfoTab = (
8180 sidebarTab && isUnitInfoTab ( sidebarTab )
8281 ) ? sidebarTab : defaultTab . unit ;
8382
8483 const unitId = sidebarComponentInfo ?. id ;
85- // istanbul ignore if: this should never happen
86- if ( ! unitId ) {
87- throw new Error ( 'unitId is required' ) ;
88- }
84+ const { data : container } = useContainer ( libraryId , unitId ) ;
8985
9086 const handleOpenUnit = useCallback ( ( ) => {
9187 if ( componentPickerMode ) {
@@ -97,12 +93,8 @@ const UnitInfo = () => {
9793
9894 const showOpenUnitButton = ! insideUnit || componentPickerMode ;
9995
100- if ( ! container ) {
101- return null ;
102- }
103-
104- const renderTab = useCallback ( ( tab : UnitInfoTab , component : React . ReactNode , title : string ) => {
105- if ( disabledTabs . includes ( tab ) ) {
96+ const renderTab = useCallback ( ( infoTab : UnitInfoTab , component : React . ReactNode , title : string ) => {
97+ if ( hiddenTabs . includes ( infoTab ) ) {
10698 // For some reason, returning anything other than empty list breaks the tab style
10799 return [ ] ;
108100 }
@@ -113,6 +105,15 @@ const UnitInfo = () => {
113105 ) ;
114106 } , [ hiddenTabs , defaultTab . unit , unitId ] ) ;
115107
108+ // istanbul ignore if: this should never happen
109+ if ( ! unitId ) {
110+ throw new Error ( 'unitId is required' ) ;
111+ }
112+
113+ if ( ! container ) {
114+ return null ;
115+ }
116+
116117 return (
117118 < Stack >
118119 { showOpenUnitButton && (
0 commit comments