React globe gl lifecycle and props
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/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.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill react_globe_gl_lifecycle_and_propsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.9 KB, 591 tokens by cl100k_base, as published. Nobody here has run it
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
{ ssr: false }to avoid server-side rendering issues. - Initialization Guard: Use a
useRefflag (e.g.,isInitialized) at the start of theuseEffect. If true, return immediately. Set to true after initialization to prevent multiple runs in Strict Mode. - Globe Configuration: Initialize the
globe.glinstance on a DOM element reference. Map the provided data props to the globe instance methods: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
rgba(255,255,255, 1), others inrgba(255,255,255, 0.5). - Arc Color: Use
#9cff00ifstatusis true, otherwise#ff2e97. - Arc Animation: Configure
arcDashLength,arcDashGap, andarcDashAnimateTime. - Labels: Set
labelTextto "city".
- Hexagon Color: Highlight ISO codes (KEN, CHN, FRA, ZAF, JPN, USA, AUS, CAN) in
- Cleanup: In the
useEffectcleanup function, callglobe._destructor()to release resources.
Constraints & Style
- Use
globe.gl(notreact-three-globeinside@react-three/fiber). - If the globe fails to render specific data after navigation, use a timestamp-based
keyprop in the parent to force a remount.
Anti-Patterns
- Do not call
globe.dispose()as it does not exist; use_destructor(). - Do not use
@react-three/fiber's<Canvas>component. - Do not rely solely on the
useEffectdependency array to prevent multiple runs; use the ref guard. - 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
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.