Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
react-native-performance-stats
Advanced tools
Get performance metrics like UI Thread FPS, JS Thread FPS, App memory and CPU (just like the "Perf Monitor").
import PerformanceStats from "react-native-performance-stats";
useEffect(() => {
const listener = PerformanceStats.addListener((stats) => {
console.log(stats);
});
// you must call .start(true) to get CPU as well
PerformanceStats.start();
// ... at some later point you could call:
// PerformanceStats.stop();
return () => listener.remove();
}, []);
✅ Compatible with the new architecture (and backwards compatible with "old arch")
yarn add react-native-performance-stats
npm i react-native-performance-stats
Run pod install:
npx pod-install
No additional steps for android are required, except when using the new react native architecture:
(Note: This setup is required to to the fact that the on android Autolinking doesn't work with the new architecture out of the box. This procedure will change in the future.)
android/app/build.gradle
file and update the file as it follows:
defaultConfig {
...
"PROJECT_BUILD_DIR=$buildDir",
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
- "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
+ "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
+ "NODE_MODULES_DIR=$rootDir/../node_modules/"
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
cppFlags "-std=c++17"
android/app/src/main/jni/Android.mk
file and update the file as it follows:
# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to include the following autogenerated makefile.
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
+
+ # Includes the MK file for `react-native-performance-stats`
+ include $(NODE_MODULES_DIR)/react-native-performance-stats/android/build/generated/source/codegen/jni/Android.mk
+
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES
setting and add the following line:
libreact_codegen_rncore \
+ libreact_codegen_performancestats \
libreact_debug \
android/app/src/main/jni/MainApplicationModuleProvider.cpp
file and update the file as it follows:
#include <answersolver.h>
+ #include <performancestats.h>
MainApplicationModuleProvider
constructor:
// auto module = samplelibrary_ModuleProvider(moduleName, params);
// if (module != nullptr) {
// return module;
// }
+ auto module = performancestats_ModuleProvider(moduleName, params);
+ if (module != nullptr) {
+ return module;
+ }
return rncore_ModuleProvider(moduleName, params);
}
true
to the .start
function to track CPU as well.react-native-performance-stats
may started tracking at another point in time than the "Perf Monitor", thus they refresh at different times.FAQs
Get FPS, memory and CPU usage of your React Native app
We found that react-native-performance-stats demonstrated a not healthy version release cadence and project activity because the last version was released 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.