Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

performance-optimizer

БесплатноБез исполняемых скриптовНе проверен

Optimize React Native app performance including bridge optimization, list rendering, memory management, and profiling. Use when app is slow, laggy, or…

armanzeroeightот armanzeroeight★ 30 звёзд на GitHub6 установок в других каталогах

Об этом скилле

Performance Optimizer

Optimize React Native app performance across rendering, bridge communication, and memory usage.

Quick Start

Common performance issues and quick fixes:

  • Slow lists: Use FlatList with proper optimization props
  • Bridge bottleneck: Batch operations, use native modules
  • Memory leaks: Clean up listeners, timers, subscriptions
  • Slow animations: Use native driver, Reanimated library

Instructions

Step 1: Profile and Identify Bottlenecks

Enable Performance Monitor:

// Shake device → "Show Perf Monitor"
// Or in code (dev only):
if (__DEV__) {
  require('react-native').PerformanceLogger.startTimespan('AppStartup');
}

Use React DevTools Profiler:

npm install -g react-devtools
react-devtools

Use Flipper:

  • Install Flipper desktop app
  • Enable React DevTools, Network, Hermes Debugger plugins
  • Profile component renders and bridge calls

Common bottlenecks:

  • Excessive re-renders
  • Bridge communication overhead
  • Large list rendering
  • Memory leaks
  • Unoptimized images

Step 2: Optimize Component Rendering

Use React.memo:

import React, { memo } from 'react';

const ExpensiveComponent = memo(({ data }) => {
  return <View>{/* Expensive rendering */}</View>;
});

// With custom comparison
const ExpensiveComponent = memo(
  ({ data }) => <View>{data.value}</View>,
  (prevProps, nextProps) => prevProps.data.id === nextProps.data.id
);

Use useMemo and useCallback:

import { useMemo, useCallback } from 'react';

function MyComponent({ items, onPress }) {
  // Memoize expensive computations
  const sortedItems = useMemo(
    () => items.sort((a, b) => a.value - b.value),
    [items]
  );
  
  // Memoize callbacks to prevent child re-renders
  const handlePress = useCallback(
    (id) => onPress(id),
    [onPress]
  );
  
  return <List items={sortedItems} onPress={handlePress} />;
}

Avoid inline functions and objects:

// Bad - creates new function on every render
<Button onPress={() => handlePress(item.id)} />

// Good - use useCallback
const handleItemPress = useCallback(() => handlePress(item.id), [item.id]);
<Button onPress={handleItemPress} />

// Bad - creates new object on every render
<View style={{ marginTop: 10 }} />

// Good - define outside or use StyleSheet
const styles = StyleSheet.create({
  container: { marginTop: 10 }
});
<View style={styles.container} />

Step 3: Optimize List Rendering

Use FlatList with optimization props:

import { FlatList } from 'react-native';

<FlatList
  data={items}
  renderItem={({ item }) => <Item data={item} />}
  keyExtractor={(item) => item.id}
  
  // Performance optimizations
  removeClippedSubviews={true}
  maxToRenderPerBatch={10}
  updateCellsBatchingPeriod={50}
  initialNumToRender={10}
  windowSize={5}
  
  // If item height is fixed
  getItemLayout={(data, index) => ({
    length: ITEM_HEIGHT,
    offset: ITEM_HEIGHT * index,
    index,
  })}
/>

Use FlashList for better performance:

npm install @shopify/flash-list
import { FlashList } from '@shopify/flash-list';

<FlashList
  data={items}
  renderItem={({ item }) => <Item data={item} />}
  estimatedItemSize={100}
/>

Optimize list items:

// Memoize list items
const Item = memo(({ data }) => {
  return (
    <View>
      <Text>{data.title}</Text>
    </View>
  );
});

// Use PureComponent for class components
class Item extends PureComponent {
  render() {
    return <View>{this.props.data.title}</View>;
  }
}

Step 4: Optimize Bridge Communication

Batch bridge calls:

// Bad - multiple bridge calls
items.forEach(item => {
  NativeModule.processItem(item);
});

// Good - single bridge call
NativeModule.processItems(items);

Use InteractionManager:

import { InteractionManager } from 'react-native';

// Defer expensive operations until after animations
InteractionManager.runAfterInteractions(() => {
  // Expensive operation
  processData();
});

Move heavy operations to native:

// For CPU-intensive tasks, create native module
import { NativeModules } from 'react-native';
const { HeavyComputation } = NativeModules;

const result = await HeavyComputation.process(largeDataset);

Step 5: Optimize Images

Use FastImage:

npm install react-native-fast-image
import FastImage from 'react-native-fast-image';

<FastImage
  source={{
    uri: imageUrl,
    priority: FastImage.priority.normal,
    cache: FastImage.cacheControl.immutable,
  }}
  resizeMode={FastImage.resizeMode.cover}
  style={{ width: 200, height: 200 }}
/>

Optimize image sizes:

// Use appropriate image sizes
<Image
  source={{ uri: imageUrl }}
  style={{ width: 100, height: 100 }}
  resizeMode="cover"
/>

// Preload images
FastImage.preload([
  { uri: image1Url },
  { uri: image2Url },
])
Полный SKILL.md на GitHub

Установить performance-optimizer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл performance-optimizer?

Optimize React Native app performance including bridge optimization, list rendering, memory management, and profiling. Use when app is slow, laggy, or consuming excessive memory. Trigger words include "performance", "optimize", "slow", "lag", "memory", "FlatList", "rendering".

Как установить скилл performance-optimizer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл performance-optimizer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить performance-optimizer с