A powerful tool for automatically detecting performance issues in your React Native app, inspired by react-scan.
- 🔍 Zero-Config Detection: Automatically highlights slow and inefficient component renders
- 🚫 No Code Changes: Drop it in and start analyzing performance
- 📱 Cross-Platform: Works on both iOS and Android
- 🧰 Flexible API: Use via import, hooks, or programmatically
- 🔄 Live Feedback: Visual highlights around components as they render
- 📊 Performance Reports: Get detailed data about render times
npm install react-native-scan
# or
yarn add react-native-scan
# or
pnpm add react-native-scan
Add to your app's entry point (e.g., App.tsx or index.js):
import React from 'react';
import { initializeScan, RenderOverlay } from 'react-native-scan';
import { View } from 'react-native';
// Initialize in development mode only
if (__DEV__) {
initializeScan({
log: true, // Optional: log render times to console
});
}
function App() {
return (
<View style={{ flex: 1 }}>
{/* Your app components */}
{/* Add the overlay to visualize renders */}
{__DEV__ && <RenderOverlay />}
</View>
);
}
export default App;
Initialize the scanning tool with options:
initializeScan({
enabled: true, // Enable/disable scanning
log: false, // Log renders to console
animationSpeed: "fast", // "slow" | "fast" | "off"
renderTimeThresholdWarn: 16, // Yellow highlight threshold (ms)
renderTimeThresholdError: 50, // Red highlight threshold (ms)
trackUnnecessaryRenders: false, // Track re-renders that don't change output
dangerouslyForceRunInProduction: false, // Not recommended!
// Optional callbacks
onRenderStart: () => {},
onRender: (componentName, renderInfo) => {},
onRenderFinish: () => {},
});
Hook API to enable/configure scanning within a component:
import { useScan } from 'react-native-scan';
function MyComponent() {
useScan({ log: true });
// ...
}
Get the collected render data:
import { getReport } from 'react-native-scan';
const report = getReport();
console.log(report);
// Output: { "ComponentName": [{ duration: 15, timestamp: 12345678 }, ...] }
setOptions(options)
: Update options at runtimegetOptions()
: Get current optionscleanupScan()
: Clean up and stop scanning
react-native-scan
patches React's component creation to:
- Measure render times of components
- Identify slow or unnecessary renders
- Visually highlight components as they render
- Collect performance data for analysis
- Only runs in development mode by default (can be forced in production but not recommended)
- Adds a small wrapper View around each component for measurement
- May have a minor impact on performance (only in development)
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library