Rocky_Mountain_Vending/.pnpm-store/v10/files/ff/72aa92168ba91f796af9dced823c8bf2ba3fd9b84a9f268b450eebe36878a88e1b26d1497edd5ecd8453cf655a4a612138d64b0ff55077036370a6fe53a109
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

41 lines
1.6 KiB
Text

import { useState, useEffect } from 'react';
import { env } from './env';
const cache = new WeakMap();
const NO_OPTIONS = {};
export function useSidecar(importer, effect) {
const options = (effect && effect.options) || NO_OPTIONS;
if (env.isNode && !options.ssr) {
return [null, null];
}
// eslint-disable-next-line react-hooks/rules-of-hooks
return useRealSidecar(importer, effect);
}
function useRealSidecar(importer, effect) {
const options = (effect && effect.options) || NO_OPTIONS;
const couldUseCache = env.forceCache || (env.isNode && !!options.ssr) || !options.async;
const [Car, setCar] = useState(couldUseCache ? () => cache.get(importer) : undefined);
const [error, setError] = useState(null);
useEffect(() => {
if (!Car) {
importer().then((car) => {
const resolved = effect ? effect.read() : car.default || car;
if (!resolved) {
console.error('Sidecar error: with importer', importer);
let error;
if (effect) {
console.error('Sidecar error: with medium', effect);
error = new Error('Sidecar medium was not found');
}
else {
error = new Error('Sidecar was not found in exports');
}
setError(() => error);
throw error;
}
cache.set(importer, resolved);
setCar(() => resolved);
}, (e) => setError(() => e));
}
}, []);
return [Car, error];
}