Beautiful map components. 100% Free, Zero config, one command setup.
TypeScript
chore: drop map error boundary from site and skill
Anmolb2b4509d530f
diff --git a/skills/mapcn/SKILL.md b/skills/mapcn/SKILL.mdindex c670482..3298e0f 100644--- a/skills/mapcn/SKILL.md+++ b/skills/mapcn/SKILL.md@@ -43,7 +43,6 @@ Never write or paste `map.tsx` by hand. If the CLI fails, read https://mapcn.dev- **Routes don't fetch.** `MapRoute` only draws the coordinates it's given; `RouteProgress` and `RouteMarker` go inside it and work from that same line. Fetch directions (OSRM, Mapbox, Google) in the parent and pass `[lng, lat][]` down. See the OSRM example linked under Routes in `references/components.md`. `MapGeoJSON` and `MapClusterLayer` take a GeoJSON object or a URL.- **Use theme colors in your own UI.** Marker content, popups and overlays are plain React, so use `bg-background`, `text-muted-foreground`, `border` and so on. Data colors on lines and fills (`MapRoute color`, paint props) can be real colors.- **Theme follows the app.** The basemap switches light/dark from a `dark` or `light` class or a `data-theme` attribute on `<html>` (next-themes works out of the box), falling back to the system preference. Pass `theme` only to force one.-- **Wrap maps in an error boundary.** `<Map>` throws if `maplibre-gl` fails to load or WebGL2 is unavailable, so without a boundary the whole page errors.- **Raw MapLibre when you need it:** `useMap()` inside `<Map>` returns `{ map, isLoaded }`, or pass a `ref` (`MapRef`) to `<Map>`. Wait for `isLoaded` before adding sources or layers, and remove them on cleanup.<!-- generated:basemap -->diff --git a/src/app/(main)/docs/_components/component-preview-client.tsx b/src/app/(main)/docs/_components/component-preview-client.tsxindex f75f548..8fa4309 100644--- a/src/app/(main)/docs/_components/component-preview-client.tsx+++ b/src/app/(main)/docs/_components/component-preview-client.tsx@@ -5,7 +5,6 @@ import { cn } from "@/lib/utils";import { Button } from "@/components/ui/button";import { CodeSurface } from "@/components/code-surface";import { CodeCopyButton } from "@/components/code-copy-button";-import { MapErrorBoundary } from "@/components/map-error-boundary";interface ComponentPreviewClientProps {children: React.ReactNode;@@ -32,7 +31,7 @@ export function ComponentPreviewClient({style={{ "--preview-height": height } as React.CSSProperties}><div className="h-(--preview-height) w-full overflow-hidden">- <MapErrorBoundary>{children}</MapErrorBoundary>+ {children}</div><div className="relative w-full overflow-hidden border-t">diff --git a/src/app/(main)/docs/installation/page.tsx b/src/app/(main)/docs/installation/page.tsxindex 21dd1a0..70be957 100644--- a/src/app/(main)/docs/installation/page.tsx+++ b/src/app/(main)/docs/installation/page.tsx@@ -10,7 +10,6 @@ import { CodeBlock } from "../_components/code-block";import { InstallCommand } from "../_components/install-command";import { Metadata } from "next";import { Card } from "@/components/ui/card";-import { MapErrorBoundary } from "@/components/map-error-boundary";import { Map, MapControls } from "@/registry/map";const cspCode = `script-src 'self' https://unpkg.com;@@ -75,11 +74,9 @@ export default function InstallationPage() {<p>Import and use the map component:</p><CodeBlock code={usageCode} /><Card className="h-[320px] overflow-hidden rounded-lg p-0">- <MapErrorBoundary>- <Map center={[-74.006, 40.7128]} zoom={11}>- <MapControls />- </Map>- </MapErrorBoundary>+ <Map center={[-74.006, 40.7128]} zoom={11}>+ <MapControls />+ </Map></Card><DocsNote><strong>Note:</strong> The map uses free CARTO basemap tiles bydiff --git a/src/app/(view)/view/[name]/page.tsx b/src/app/(view)/view/[name]/page.tsxindex 319baee..915dc33 100644--- a/src/app/(view)/view/[name]/page.tsx+++ b/src/app/(view)/view/[name]/page.tsx@@ -1,4 +1,3 @@-import { MapErrorBoundary } from "@/components/map-error-boundary";import { slugToTitle } from "@/lib/utils";import { blockComponents } from "@/registry/blocks/__index__";import { notFound } from "next/navigation";@@ -37,9 +36,7 @@ export default async function BlockViewPage({ params }: BlockViewPageProps) {return (<div className="bg-background min-h-screen">- <MapErrorBoundary className="min-h-screen">- <Component />- </MapErrorBoundary>+ <Component /></div>);}diff --git a/src/components/map-error-boundary.tsx b/src/components/map-error-boundary.tsxdeleted file mode 100644index ccd88d9..0000000--- a/src/components/map-error-boundary.tsx+++ /dev/null@@ -1,39 +0,0 @@-"use client";--import { Component, type ReactNode } from "react";-import { cn } from "@/lib/utils";--interface MapErrorBoundaryProps {- children: ReactNode;- className?: string;-}--interface MapErrorBoundaryState {- failed: boolean;-}--export class MapErrorBoundary extends Component<- MapErrorBoundaryProps,- MapErrorBoundaryState-> {- state: MapErrorBoundaryState = { failed: false };-- static getDerivedStateFromError(): MapErrorBoundaryState {- return { failed: true };- }-- render() {- if (!this.state.failed) return this.props.children;-- return (- <div- className={cn(- "text-muted-foreground flex size-full items-center justify-center text-sm",- this.props.className,- )}- >- Map failed to load- </div>- );- }-}