UNPKG

@atlaskit/side-navigation

Version:

A highly composable side navigation component that supports nested views.

23 lines (22 loc) • 956 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); var _NestableNavigationContent = require("../components/NestableNavigationContent"); var useChildIds = function useChildIds(currentStackId, committedStack, onUnknownNest) { var childIdsRef = (0, _react.useRef)(new Set()); (0, _react.useEffect)(function () { // we are holding navigation item IDs in childIdsRef // check if the current displayed nav item (currentStackId) is in childIdsRef. if it's not, this means it's undefined if (currentStackId === _NestableNavigationContent.ROOT_ID || !childIdsRef.current.size || childIdsRef.current.has(currentStackId) || !onUnknownNest) { return; } onUnknownNest(committedStack || [currentStackId]); }, [currentStackId, committedStack, onUnknownNest]); return { childIdsRef: childIdsRef }; }; var _default = exports.default = useChildIds;