gluestack-ui-v4:performance
Performance optimization and cross-platform patterns for gluestack-ui v4 - covers native/web compatibility, TypeScript, memoization, animations, and best practices.
What this skill does
# Gluestack UI v4 - Performance & Cross-Platform
This sub-skill focuses on performance optimization, cross-platform compatibility, and React Native best practices for gluestack-ui v4.
## Rule 12: Cross-Platform Rendering (Native & Web)
Gluestack UI v4 components are designed to work seamlessly on both React Native (iOS/Android) and Web platforms. Always use Gluestack wrapper components instead of direct React Native imports to ensure cross-platform compatibility.
### Critical Rule: Always Use Gluestack Wrappers
**NEVER import components directly from `react-native`** when a Gluestack wrapper exists. Gluestack wrappers handle platform-specific differences automatically.
### Platform-Specific Component Mapping
| React Native Import | Gluestack Wrapper | Notes |
|---------------------|-------------------|-------|
| `KeyboardAvoidingView` from `react-native` | `KeyboardAvoidingView` from `@/components/ui/keyboard-avoiding-view` | Required for web compatibility |
| `Platform` from `react-native` | Use only when absolutely necessary | Prefer Gluestack's built-in platform handling |
| `View`, `Text`, etc. | `Box`, `Text` from `@/components/ui/*` | Always use Gluestack components |
### Correct Pattern: Cross-Platform Components
```tsx
// ✅ CORRECT: Using Gluestack KeyboardAvoidingView wrapper
import { KeyboardAvoidingView } from '@/components/ui/keyboard-avoiding-view';
import { Platform } from 'react-native'; // Only when needed for platform-specific logic
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
className="flex-1"
>
<ScrollView>
{/* Content */}
</ScrollView>
</KeyboardAvoidingView>
```
### Incorrect Pattern: Direct React Native Imports
```tsx
// ❌ INCORRECT: Direct import from react-native
import { KeyboardAvoidingView, Platform } from 'react-native';
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
{/* This may not work correctly on web */}
</KeyboardAvoidingView>
```
### Web-Specific Considerations
1. **KeyboardAvoidingView**: The Gluestack wrapper handles web gracefully (web doesn't need keyboard avoidance)
2. **SafeAreaView**: Works on both native and web (web treats it as a regular View)
3. **ScrollView**: Works identically on both platforms
4. **Platform.select**: Only use when absolutely necessary; prefer Gluestack's built-in handling
### Testing Cross-Platform Compatibility
Always test components on both platforms:
1. **Native**: Run `npm run ios` or `npm run android`
2. **Web**: Run `npm run web` and verify in browser
3. **Verify**: Check that all components render correctly and interactions work on both platforms
### Platform-Specific Code (When Necessary)
If you must use platform-specific code, use it sparingly and document why:
```tsx
// Acceptable: Platform-specific behavior when Gluestack doesn't cover it
import { Platform } from 'react-native';
const keyboardBehavior = Platform.OS === 'ios' ? 'padding' : 'height';
<KeyboardAvoidingView behavior={keyboardBehavior} className="flex-1">
{/* Content */}
</KeyboardAvoidingView>
```
### Common Cross-Platform Issues to Avoid
1. **Direct React Native imports** - Always use Gluestack wrappers
2. **Platform-specific styling without fallbacks** - Ensure web has equivalent styles
3. **Native-only APIs** - Check if web alternatives exist
4. **Missing web polyfills** - Gluestack handles most of these automatically
### Verification Checklist for Cross-Platform
- [ ] All components imported from `@/components/ui/*` wrappers
- [ ] No direct imports from `react-native` for wrapped components
- [ ] KeyboardAvoidingView uses Gluestack wrapper
- [ ] Tested on both native (iOS/Android) and web platforms
- [ ] All interactions work on both platforms
- [ ] Styling renders correctly on both platforms
- [ ] No platform-specific code without documentation
## Rule 13: Performance & Best Practices
Follow these best practices to ensure optimal performance, type safety, and maintainability in React Native/Expo applications.
### Use TypeScript
Define navigation and prop types for type safety. This catches errors at compile time and improves developer experience.
#### Correct Pattern
```tsx
// ✅ CORRECT: Typed component props
interface LoginFormProps {
readonly onSubmit: (email: string, password: string) => void;
readonly isLoading?: boolean;
}
const LoginForm = ({ onSubmit, isLoading = false }: LoginFormProps) => {
// Component implementation
};
// ✅ CORRECT: Typed navigation
import { useRouter } from 'expo-router';
const router = useRouter();
router.push('/login' as any); // Type-safe navigation
```
#### Incorrect Pattern
```tsx
// ❌ INCORRECT: No type definitions
const LoginForm = ({ onSubmit, isLoading }) => {
// No type safety
};
```
### Memoize Components
Use `React.memo` and `useCallback` to prevent unnecessary rerenders, especially for expensive components or frequently re-rendered parent components.
#### Correct Pattern
```tsx
// ✅ CORRECT: Memoized component
import React, { useCallback, useState } from 'react';
const ExpensiveComponent = React.memo(({ data, onUpdate }: Props) => {
// Expensive rendering logic
});
const ParentComponent = () => {
const [count, setCount] = useState(0);
// Memoized callback prevents child rerenders
const handleUpdate = useCallback((value: string) => {
// Update logic
}, []);
return (
<>
<Button onPress={() => setCount(count + 1)}>
<ButtonText>Count: {count}</ButtonText>
</Button>
<ExpensiveComponent data={data} onUpdate={handleUpdate} />
</>
);
};
```
#### When to Memoize
- Components that receive stable props but parent rerenders frequently
- Callbacks passed to child components
- Expensive computations (use `useMemo`)
### Run Animations on UI Thread
Use Reanimated worklets for 60fps animations. This keeps animations smooth by running on the native UI thread instead of the JavaScript thread.
#### Correct Pattern
```tsx
// ✅ CORRECT: Using Reanimated worklets
import { useSharedValue, withTiming } from 'react-native-reanimated';
import Animated from 'react-native-reanimated';
const AnimatedBox = Animated.createAnimatedComponent(Box);
const Component = () => {
const translateX = useSharedValue(0);
const handlePress = () => {
// Animation runs on UI thread
translateX.value = withTiming(100, { duration: 300 });
};
return (
<AnimatedBox
style={{
transform: [{ translateX }],
}}
>
<Pressable onPress={handlePress}>
<Text>Animate</Text>
</Pressable>
</AnimatedBox>
);
};
```
#### Incorrect Pattern
```tsx
// ❌ INCORRECT: Using Animated API (runs on JS thread)
import { Animated } from 'react-native';
const Component = () => {
const translateX = new Animated.Value(0);
// This runs on JavaScript thread, can cause jank
};
```
### Handle Safe Areas
Use `SafeAreaView` or `useSafeAreaInsets` to handle device notches, status bars, and home indicators properly.
#### Correct Pattern
```tsx
// ✅ CORRECT: Using SafeAreaView
import { SafeAreaView } from '@/components/ui/safe-area-view';
const Screen = () => (
<SafeAreaView className="flex-1 bg-background">
<VStack className="p-4">
{/* Content */}
</VStack>
</SafeAreaView>
);
// ✅ CORRECT: Using useSafeAreaInsets for custom layouts
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const CustomLayout = () => {
const insets = useSafeAreaInsets();
return (
<Box style={{ paddingTop: insets.top }}>
{/* Content */}
</Box>
);
};
```
### Test on Real Devices
Simulator/emulator performance differs from real devices. Always test on physical devices before releasing.
#### Testing Checklist
- [ ] Test on real iOS device (iPhone/iPad)
- [ ] Test on real Android device
- [ ] Test on different screen sizes
- [ ] Test with different OS versions
- [ ] Test performance under load
- [ ] Test with slow network conditions
### Use FlatList Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.