Files
url_tracker_tool/node_modules/use-sidecar/dist/es2019/renderProp.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

29 lines
1.2 KiB
JavaScript

import * as React from 'react';
import { useState, useCallback, useEffect, useLayoutEffect } from 'react';
export function renderCar(WrappedComponent, defaults) {
function State({ stateRef, props }) {
const renderTarget = useCallback(function SideTarget(...args) {
useLayoutEffect(() => {
stateRef.current(args);
});
return null;
}, []);
// @ts-ignore
return React.createElement(WrappedComponent, { ...props, children: renderTarget });
}
const Children = React.memo(({ stateRef, defaultState, children }) => {
const [state, setState] = useState(defaultState.current);
useEffect(() => {
stateRef.current = setState;
}, []);
return children(...state);
}, () => true);
return function Combiner(props) {
const defaultState = React.useRef(defaults(props));
const ref = React.useRef((state) => (defaultState.current = state));
return (React.createElement(React.Fragment, null,
React.createElement(State, { stateRef: ref, props: props }),
React.createElement(Children, { stateRef: ref, defaultState: defaultState, children: props.children })));
};
}