fix: use SuperJSON for cache persistence and add null guards to all widgets
SuperJSON preserves Date/Map/Set types through the Redis cache round-trip, fixing RangeError crashes from date formatting. Added defensive null/undefined guards across all widget components to handle useQuery loading states and potential cache shape mismatches.
This commit is contained in:
31 files changed
+124
-117
No files matched your search
@@ -35,8 +35,9 @@ export default function StockPriceWidget({ options, width, height }: WidgetCompo
|
||||
calculateChangePercentage(data.priceHistory.at(-1) ?? 0, data.previousClose),
|
||||
);
|
||||
|
||||
const stockValuesMin = Math.min(...data.priceHistory);
|
||||
const stockGraphValues = data.priceHistory.map((value) => value - stockValuesMin + 50);
|
||||
const priceHistory = data.priceHistory ?? [];
|
||||
const stockValuesMin = priceHistory.length > 0 ? Math.min(...priceHistory) : 0;
|
||||
const stockGraphValues = priceHistory.map((value) => value - stockValuesMin + 50);
|
||||
const trendColor = stockValuesChange > 0 ? "green.7" : stockValuesChange < 0 ? "red.7" : "gray.6";
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user