Rocky_Mountain_Vending/.pnpm-store/v10/files/1f/5b44648824c9621a59d78d1a69d1c0624e85f1f2291e6e9ca7e041a9e9360990ac4543a49174a527e75978f3e24ad704549185d6363c587fb8cca8f610a7c7
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

53 lines
No EOL
2 KiB
Text

import { Children, useEffect, useLayoutEffect } from 'react';
const isServer = typeof window === 'undefined';
const useClientOnlyLayoutEffect = isServer ? ()=>{} : useLayoutEffect;
const useClientOnlyEffect = isServer ? ()=>{} : useEffect;
export default function SideEffect(props) {
const { headManager, reduceComponentsToState } = props;
function emitChange() {
if (headManager && headManager.mountedInstances) {
const headElements = Children.toArray(Array.from(headManager.mountedInstances).filter(Boolean));
headManager.updateHead(reduceComponentsToState(headElements));
}
}
if (isServer) {
headManager?.mountedInstances?.add(props.children);
emitChange();
}
useClientOnlyLayoutEffect(()=>{
headManager?.mountedInstances?.add(props.children);
return ()=>{
headManager?.mountedInstances?.delete(props.children);
};
});
// We need to call `updateHead` method whenever the `SideEffect` is trigger in all
// life-cycles: mount, update, unmount. However, if there are multiple `SideEffect`s
// being rendered, we only trigger the method from the last one.
// This is ensured by keeping the last unflushed `updateHead` in the `_pendingUpdate`
// singleton in the layout effect pass, and actually trigger it in the effect pass.
useClientOnlyLayoutEffect(()=>{
if (headManager) {
headManager._pendingUpdate = emitChange;
}
return ()=>{
if (headManager) {
headManager._pendingUpdate = emitChange;
}
};
});
useClientOnlyEffect(()=>{
if (headManager && headManager._pendingUpdate) {
headManager._pendingUpdate();
headManager._pendingUpdate = null;
}
return ()=>{
if (headManager && headManager._pendingUpdate) {
headManager._pendingUpdate();
headManager._pendingUpdate = null;
}
};
});
return null;
}
//# sourceMappingURL=side-effect.js.map