UNPKG

@grafana/faro-react

Version:

Faro package that enables easier integration in projects built with React.

31 lines 1.74 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.withFaroProfiler = void 0; var jsx_runtime_1 = require("react/jsx-runtime"); var hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics")); var faro_core_1 = require("@grafana/faro-core"); var FaroProfiler_1 = require("./FaroProfiler"); function withFaroProfiler(WrappedComponent, options) { var _a, _b, _c; var componentDisplayName = (_c = (_b = (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : WrappedComponent.displayName) !== null && _b !== void 0 ? _b : WrappedComponent.name) !== null && _c !== void 0 ? _c : faro_core_1.unknownString; var Component = function (props) { return ((0, jsx_runtime_1.jsx)(FaroProfiler_1.FaroProfiler, __assign({ name: componentDisplayName, updateProps: props }, { children: (0, jsx_runtime_1.jsx)(WrappedComponent, __assign({}, props)) }))); }; Component.displayName = "faroProfiler(".concat(componentDisplayName, ")"); (0, hoist_non_react_statics_1.default)(Component, WrappedComponent); return Component; } exports.withFaroProfiler = withFaroProfiler; //# sourceMappingURL=withFaroProfiler.js.map