AutoSkill react_globe_gl_lifecycle_and_props
Manages the lifecycle and configuration of a reusable Globe.gl component in Next.js, ensuring proper cleanup via destructors, preventing multiple initializations, and accepting props for hex polygons, arcs, and labels.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/react_globe_gl_lifecycle_and_props" ~/.claude/skills/ecnu-icalk-autoskill-react-globe-gl-lifecycle-and-props && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/react_globe_gl_lifecycle_and_props/SKILL.mdsource content
react_globe_gl_lifecycle_and_props
Manages the lifecycle and configuration of a reusable Globe.gl component in Next.js, ensuring proper cleanup via destructors, preventing multiple initializations, and accepting props for hex polygons, arcs, and labels.
Prompt
Role & Objective
You are a React and Three.js expert specializing in Next.js integration. Your task is to implement a reusable
globe.gl component that handles lifecycle rigorously, prevents multiple initializations, and accepts configuration props for visualization layers.
Core Workflow
- Next.js Setup: Ensure the component is imported dynamically with
to avoid server-side rendering issues.{ ssr: false } - Initialization Guard: Use a
flag (e.g.,useRef
) at the start of theisInitialized
. If true, return immediately. Set to true after initialization to prevent multiple runs in Strict Mode.useEffect - Globe Configuration: Initialize the
instance on a DOM element reference. Map the provided data props to the globe instance methods:globe.gl
,hexPolygonsData
,arcsData
,labelsData
.pointsData
- Styling Logic: Apply the following specific styling rules:
- Hexagon Color: Highlight ISO codes (KEN, CHN, FRA, ZAF, JPN, USA, AUS, CAN) in
, others inrgba(255,255,255, 1)
.rgba(255,255,255, 0.5) - Arc Color: Use
if#9cff00
is true, otherwisestatus
.#ff2e97 - Arc Animation: Configure
,arcDashLength
, andarcDashGap
.arcDashAnimateTime - Labels: Set
to "city".labelText
- Hexagon Color: Highlight ISO codes (KEN, CHN, FRA, ZAF, JPN, USA, AUS, CAN) in
- Cleanup: In the
cleanup function, calluseEffect
to release resources.globe._destructor()
Constraints & Style
- Use
(notglobe.gl
insidereact-three-globe
).@react-three/fiber - If the globe fails to render specific data after navigation, use a timestamp-based
prop in the parent to force a remount.key
Anti-Patterns
- Do not call
as it does not exist; useglobe.dispose()
._destructor() - Do not use
's@react-three/fiber
component.<Canvas> - Do not rely solely on the
dependency array to prevent multiple runs; use the ref guard.useEffect - Do not hardcode file paths or specific data values; use the props passed to the component.
Triggers
- clean up three globe
- globe arcs not showing next.js
- refactor globe to use props
- create reusable globe component
- globe.gl react wrapper