Files
url_tracker_tool/node_modules/react-focus-lock/dist/es2015/clientSideEffect.js
Andrei 58f8093689 Rebrand from 'Redirect Intelligence v2' to 'URL Tracker Tool V2' throughout UI
- Updated all component headers and documentation
- Changed navbar and footer branding
- Updated homepage hero badge
- Modified page title in index.html
- Simplified footer text to 'Built with ❤️'
- Consistent V2 capitalization across all references
2025-08-19 19:12:23 +00:00

44 lines
1.5 KiB
JavaScript

import React, { useEffect, useRef } from 'react';
function withSideEffect(reducePropsToState, handleStateChangeOnClient) {
if (process.env.NODE_ENV !== 'production') {
if (typeof reducePropsToState !== 'function') {
throw new Error('Expected reducePropsToState to be a function.');
}
if (typeof handleStateChangeOnClient !== 'function') {
throw new Error('Expected handleStateChangeOnClient to be a function.');
}
}
return function wrap(WrappedComponent) {
if (process.env.NODE_ENV !== 'production') {
if (typeof WrappedComponent !== 'function') {
throw new Error('Expected WrappedComponent to be a React component.');
}
}
var mountedInstances = [];
function emitChange() {
console.log('emitting');
var state = reducePropsToState(mountedInstances.map(function (instance) {
return instance.current;
}));
handleStateChangeOnClient(state);
}
var SideEffect = function SideEffect(props) {
var lastProps = useRef(props);
useEffect(function () {
lastProps.current = props;
});
useEffect(function () {
console.log('ins added');
mountedInstances.push(lastProps);
return function () {
console.log('ins removed');
var index = mountedInstances.indexOf(lastProps);
mountedInstances.splice(index, 1);
};
}, []);
return /*#__PURE__*/React.createElement(WrappedComponent, props);
};
return SideEffect;
};
}
export default withSideEffect;