You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Использование Profiler<Profilerid="GroupList"onRender={(id,phase,actualDuration)=>{console.log(`Component ${id} took ${actualDuration}ms to ${phase}`);}}><GroupList/></Profiler>
Метрики производительности
import{PerformanceObserver,performance}from'react-native-performance';// Отслеживание производительностиconstobserver=newPerformanceObserver((list)=>{constentries=list.getEntries();entries.forEach((entry)=>{console.log(`${entry.name}: ${entry.duration}ms`);});});observer.observe({entryTypes: ['measure']});// Измерение времени операцииperformance.mark('startOperation');// ... выполнение операцииperformance.mark('endOperation');performance.measure('operationDuration','startOperation','endOperation');
Оптимизация памяти
Очистка ресурсов
// Правильная очистка в useEffectuseEffect(()=>{constsubscription=eventEmitter.addListener('event',handler);return()=>{subscription.remove();};},[]);
Управление размером списков
// Пагинация для длинных списковconstPaginatedList: React.FC=()=>{const[page,setPage]=useState(1);const[data,setData]=useState<Item[]>([]);constloadMore=useCallback(()=>{setPage(prev=>prev+1);},[]);return(<FlatListdata={data}onEndReached={loadMore}onEndReachedThreshold={0.5}removeClippedSubviews={true}maxToRenderPerBatch={10}/>);};