"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Backstage
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDefaultBackstageItems = void 0;
const React = require("react");
/** Hook that returns items from [[BackstageItemsManager]].
 * @internal
 */
const useDefaultBackstageItems = (manager) => {
    const [items, setItems] = React.useState(manager.items);
    const isInitialMount = React.useRef(true);
    React.useEffect(() => {
        if (isInitialMount.current)
            isInitialMount.current = false;
        else {
            setItems(manager.items);
        }
    }, [manager, manager.items]);
    React.useEffect(() => {
        return manager.onItemsChanged.addListener((args) => {
            setItems(args.items);
        });
    }, [manager]);
    return items;
};
exports.useDefaultBackstageItems = useDefaultBackstageItems;
//# sourceMappingURL=useDefaultBackstageItems.js.map