Profiling in production
henninghall opened this issue · comments
React Profiler seem to be missing in production bundles by default and render tracing is therefore not working in production builds.
Here is an explanation on how to enable react profiling with webpack or create react app. Is there a way to enable this in react native / metro?
To reproduce:
- Clone this repo and run vanilla project.
- Put an alert within the
traceRender()
in App.tsx. - Run android
- Open dev menu -> Settings -> Disable "JS Dev Mode" -> Reload app
- Alerts are only shown in DEV mode.
Found a solution with this patch.
diff --git a/node_modules/react-native/Libraries/Renderer/shims/ReactNative.js b/node_modules/react-native/Libraries/Renderer/shims/ReactNative.js
index debaf0a..81744db 100644
--- a/node_modules/react-native/Libraries/Renderer/shims/ReactNative.js
+++ b/node_modules/react-native/Libraries/Renderer/shims/ReactNative.js
@@ -19,7 +19,7 @@ let ReactNative;
if (__DEV__) {
ReactNative = require('../implementations/ReactNativeRenderer-dev');
} else {
- ReactNative = require('../implementations/ReactNativeRenderer-prod');
+ ReactNative = require('../implementations/ReactNativeRenderer-profiling');
}
module.exports = (ReactNative: ReactNativeType);