
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
optic-react-native
Advanced tools
A lightweight performance monitoring tool for React Native applications. Track startup time, network requests, FPS, and custom traces in real-time.
npm install @useoptic/react-native
# or
yarn add @useoptic/react-native
import { initOptic } from '@useoptic/react-native';
initOptic();
import { OpticProvider } from '@useoptic/react-native';
const App = () => (
<>
<OpticProvider>
<YourAppContent />
<OpticProvider />
</>
);
Use the tracing API to measure specific interactions in your app:
import { startTrace, endTrace } from '@useoptic/react-native';
const handleButtonPress = async () => {
startTrace('ButtonPress');
try {
await someAsyncOperation();
} finally {
endTrace('ButtonPress', 'ButtonComponent');
}
};
Monitor component re-renders using the useRenderMonitor hook:
import { useRenderMonitor } from '@useoptic/react-native';
const MyComponent = () => {
useRenderMonitor('MyComponent');
// ... your component code
};
interface InitOpticOptions {
enabled?: boolean; // Enable/disable all metrics (default: true)
startup?: boolean; // Track startup time (default: true)
network?: boolean; // Track network requests (default: true)
reRenders?: boolean; // Track component re-renders (default: true)
traces?: boolean; // Enable custom tracing (default: true)
onMetricsLogged?: (metrics: any) => void; // Callback for metrics updates
}
We welcome contributions! Here's how you can help:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)yarn installyarn testyarn buildMIT © Optic
Copyright (c) 2024 Optic
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
enabledbooleantruefalse, disables all metrics and hides the overlay. Useful for turning off performance tracking in production or for specific builds.onMetricsLogged(metrics: any) => voidimport { initOptic } from '@useoptic/react-native';
initOptic({
enabled: true, // Set to false to disable metrics and overlay
onMetricsLogged: (metrics) => {
// Log metrics or send to your API
fetch('https://your-api.com/metrics', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(metrics),
});
},
// ...other options
});
For more details on all options, see the API documentation section.
useRenderMonitorTo test and visualize component re-renders in the overlay, use the useRenderMonitor hook in your components. This will increment the re-render count for the component in the metrics overlay.
import React from 'react';
import { useRenderMonitor } from '@useoptic/react-native';
export const TestComponent = () => {
useRenderMonitor('Home');
const [count, setCount] = React.useState(0);
return (
<View>
<Text>Render count: {count}</Text>
<Button title="Re-render" onPress={() => setCount(count + 1)} />
</View>
);
};
useRenderMonitor will appear in the "Re-renders" section of the overlay.Add this component to your app and interact with it to see re-render tracking in action in the overlay.
FAQs
React Native library for Optic
We found that optic-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.