Liferay.Loader.define("app-builder-web@1.0.76/js/hooks/useLoader.es", ['module', 'exports', 'require', 'frontend-js-react-web', 'frontend-js-react-web$react'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = useLoader;

    var _frontendJsReactWeb = require("frontend-js-react-web");

    var _react = require("frontend-js-react-web$react");

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var EmptyModule = {
      default: function _default() {
        return null;
      }
    };

    function useLoader() {
      var modules = (0, _react.useRef)(new Map());
      var isMounted = (0, _frontendJsReactWeb.useIsMounted)();
      return (0, _react.useCallback)(function (module) {
        if (!modules.current.has(module)) {
          modules.current.set(module, new Promise(function (resolve) {
            Liferay.Loader.require([module], function (Module) {
              if (isMounted()) {
                resolve(Module ? Module : EmptyModule);
              }
            }, function (error) {

              if (isMounted()) {
                resolve(EmptyModule);
              }
            });
          }));
        }

        return modules.current.get(module);
      }, [isMounted]);
    }
    //# sourceMappingURL=useLoader.es.js.map
  }
});
//# sourceMappingURL=useLoader.es.js.map