Rocky_Mountain_Vending/.pnpm-store/v10/files/7c/0e5abe73875e73c79d4b88d21e6f6d76d098336c01a767587bd27f0cc4dbff8fb2aa08c696ec1aa969ce29c4bf01bda8f906fd47628fc025f8e2a10a28de8e
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

55 lines
No EOL
2.7 KiB
Text

export const REACT_HYDRATION_ERROR_LINK = 'https://react.dev/link/hydration-mismatch';
export const NEXTJS_HYDRATION_ERROR_LINK = 'https://nextjs.org/docs/messages/react-hydration-error';
/**
* Only React 19+ contains component stack diff in the error message
*/ const errorMessagesWithComponentStackDiff = [
/^In HTML, (.+?) cannot be a child of <(.+?)>\.(.*)\nThis will cause a hydration error\.(.*)/,
/^In HTML, (.+?) cannot be a descendant of <(.+?)>\.\nThis will cause a hydration error\.(.*)/,
/^In HTML, text nodes cannot be a child of <(.+?)>\.\nThis will cause a hydration error\./,
/^In HTML, whitespace text nodes cannot be a child of <(.+?)>\. Make sure you don't have any extra whitespace between tags on each line of your source code\.\nThis will cause a hydration error\./
];
export function isHydrationError(error) {
return isErrorMessageWithComponentStackDiff(error.message) || /Hydration failed because the server rendered (text|HTML) didn't match the client\./.test(error.message) || /A tree hydrated but some attributes of the server rendered HTML didn't match the client properties./.test(error.message);
}
export function isErrorMessageWithComponentStackDiff(msg) {
return errorMessagesWithComponentStackDiff.some((regex)=>regex.test(msg));
}
export function getHydrationErrorStackInfo(error) {
const errorMessage = error.message;
if (isErrorMessageWithComponentStackDiff(errorMessage)) {
const [message, diffLog = ''] = errorMessage.split('\n\n');
const diff = diffLog.trim();
return {
message: diff === '' ? errorMessage.trim() : message.trim(),
diff,
notes: null
};
}
const [message, maybeComponentStackDiff] = errorMessage.split(`${REACT_HYDRATION_ERROR_LINK}`);
const trimmedMessage = message.trim();
// React built-in hydration diff starts with a newline
if (maybeComponentStackDiff !== undefined && maybeComponentStackDiff.length > 1) {
const diffs = [];
maybeComponentStackDiff.split('\n').forEach((line)=>{
if (line.trim() === '') return;
if (!line.trim().startsWith('at ')) {
diffs.push(line);
}
});
const [displayedMessage, ...notes] = trimmedMessage.split('\n\n');
return {
message: displayedMessage,
diff: diffs.join('\n'),
notes: notes.join('\n\n') || null
};
} else {
const [displayedMessage, ...notes] = trimmedMessage.split('\n\n');
return {
message: displayedMessage,
diff: null,
notes: notes.join('\n\n')
};
}
}
//# sourceMappingURL=react-19-hydration-error.js.map