Showing 1–9 of 9
1export async function fetchJson<T>(2 url: string,3 init?: RequestInit4): Promise<T> {5 const response = await fetch(url, init);6 if (!response.ok) {7 throw new Error(`HTTP ${response.status}`);8 }9 return response.json() as Promise<T>;10}➜ pixel-patterns git:(main) npm install added 412 packages in 6s ✔ 0 vulnerabilities ➜ pixel-patterns git:(main) npm run dev ▲ Next.js 14.2.35 - Local: http://localhost:3000 ➜
$ npm install @tanstack/react-query
$ pnpm add @tanstack/react-query
$ yarn add @tanstack/react-query
$ bun add @tanstack/react-query
12 export const siteConfig = {
13− name: "Pixel UI",
14− theme: "light",
13+ name: "Pixel Patterns",
14+ theme: "dark",
15+ locale: "en-US",
16 };
{
"id": 42,
"name": "Ada Lovelace",
"roles": ["admin", "editor"],
"verified": true,
"lastLogin": null
}TypeError: Cannot read properties of undefined (reading 'map')
Unhandled runtime error · 1 of 1
Tip: guard optional data with users?.map(...) ?? []
Run npm run dev and open localhost:3000.
Press ⌘ K to search, or Shift + ?
for all shortcuts. Config lives in next.config.mjs.
useEffect(() => {
setTotal(
items.reduce(sum, 0)
);
}, [items]);
const total = useMemo( () => items.reduce(sum, 0), [items] );