@embrace-io/react-native-navigation
Version:
A React Native wrapper for the OTel Navigation instrumentation library that creates telemetry data representing Navigation changes
30 lines (29 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbraceNavigationWrapper = void 0;
const React = require("react");
const react_1 = require("react");
const EMBRACE_ATTRIBUTES = {
"emb.type": "ux.view",
};
const EmbraceNavigationWrapper = (NavigationComponent) => {
const WrappedNavigationComponent = (0, react_1.forwardRef)((props, ref) => {
const { children, tracerProvider, screenAttributes, debug = true, tracerOptions, } = props;
const attributes = (0, react_1.useMemo)(() => {
if (screenAttributes) {
return Object.assign(Object.assign({}, screenAttributes), EMBRACE_ATTRIBUTES);
}
return EMBRACE_ATTRIBUTES;
}, [screenAttributes]);
return (React.createElement(NavigationComponent, { ref: ref, provider: tracerProvider, config: {
attributes,
debug,
tracerOptions,
} }, children));
});
// displayName goes on the forwardRef component (not the factory) so
// React DevTools and react/display-name can see it.
WrappedNavigationComponent.displayName = "EmbraceNavigationWrapper";
return WrappedNavigationComponent;
};
exports.EmbraceNavigationWrapper = EmbraceNavigationWrapper;