fix: resolve black screen caused by React hooks violation in WaterfallModal

Move useMemo before early return in WaterfallModal to comply with Rules of Hooks.
Wrap App with ErrorBoundary so future render crashes show an error panel instead of a silent black screen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-03-16 13:04:42 +01:00
co-authored by Claude Sonnet 4.6
parent 753b312412
commit 845a8e0ae6
2 changed files with 9 additions and 5 deletions
+5 -4
View File
@@ -11,13 +11,12 @@ interface WaterfallModalProps {
}
export const WaterfallModal: React.FC<WaterfallModalProps> = ({ product, includeCOGS, onClose }) => {
if (!product) return null;
const data = useMemo(() => {
if (!product) return [];
const metrics = calculateProductMetrics(product, includeCOGS);
let currentTotal = product.grossSales;
const steps = [
{ name: 'Gross Sales', value: product.grossSales, isTotal: true, color: '#6366f1' }, // Indigo
{ name: 'PPC', value: -product.ppcSpend, isTotal: false, color: '#ef4444' }, // Rose
@@ -67,6 +66,8 @@ export const WaterfallModal: React.FC<WaterfallModalProps> = ({ product, include
}));
}, [product, includeCOGS]);
if (!product) return null;
const metrics = calculateProductMetrics(product, includeCOGS);
return (