Skip to content

Commit bac89b4

Browse files
authored
docs: update example and add docs (#4)
* docs: update example and add docs * docs: use gif * docs: add banner * docs: add badges * docs: add badges * docs: update
1 parent ad1fd33 commit bac89b4

12 files changed

Lines changed: 787 additions & 29 deletions

File tree

README.md

Lines changed: 119 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
1+
![release-inspector-banner](./docs/assets/banner.png)
2+
3+
[![mit licence][license-badge]][license]
4+
[![npm downloads][npm-downloads-badge]][npm-downloads]
5+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
6+
17
# react-native-release-inspector
28

3-
Profile React Native App in Release mode with React DevTools for React.Profiler
9+
The React on Web allows the users to run [profilable](https://react.dev/reference/dev-tools/react-performance-tracks#using-profiling-builds) builds to get near to production experience. This is the sweetest spot to having more confident profiling. However, on React Native this wasn't possible until now.
10+
11+
This package fixes this gap following the same analogy from React on Web, by allowing React Native to load Profiling shim for Release builds. 🚀
12+
13+
## Demo
14+
15+
![release-inspector](./docs/assets/inspector.gif)
16+
17+
<hr/>
18+
19+
## Applications
20+
21+
**Why you need this?**
22+
23+
#### Profiling React Components in Release builds
24+
25+
Most teams leverage React DevTools to profile their components in Debug Builds. If you are looking to profile React Components in Release builds, then this package is for you.
26+
27+
![Release Profilng](./docs/assets/release.png)
28+
29+
#### Inspecting React.Profiler callbacks in Release builds
30+
31+
Teams can have a use case where they leverage `React.Profiler` and perform their calculations from the values of the `onRender` callback. In debug builds, this works very well. If you are also interested in running these calculations in release builds, then this package is for you.
32+
33+
```ts
34+
function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime) {
35+
// Aggregate or log render timings...
36+
}
37+
38+
<Profiler id="App" onRender={onRender}>
39+
<App />
40+
</Profiler>
41+
```
442

543
## Installation
644

@@ -10,29 +48,100 @@ npm install @callstack/react-native-release-inspector
1048

1149
## Usage
1250

13-
```js
14-
import { multiply } from '@callstack/react-native-release-inspector';
51+
#### Step 1:
52+
Add this to the top level of `index.js`:
1553

16-
// ...
54+
```diff
55+
+import '@callstack/react-native-release-inspector';
56+
import { AppRegistry } from 'react-native';
57+
```
1758

18-
const result = multiply(3, 7);
59+
#### Step 2:
60+
Update your `metro.config` with `withReactNativeReleaseInspector`:
61+
62+
```diff
63+
+const {
64+
+ withReactNativeReleaseInspector,
65+
+} = require('@callstack/react-native-release-inspector/metro');
66+
67+
const root = path.resolve(__dirname, '../..');
68+
69+
const config = withMetroConfig(getDefaultConfig(__dirname), {
70+
root,
71+
dirname: __dirname,
72+
});
73+
74+
+module.exports = withReactNativeReleaseInspector(config, true);
1975
```
2076

21-
## Repository structure
77+
#### Step 3:
78+
Start the inspector in a terminal:
2279

23-
- Library package: `packages/react-native-release-inspector`
24-
- Example app: `apps/example`
80+
```bash
81+
npx inspector start
82+
```
83+
84+
<br/>
85+
Now build and run your app in release mode, you should see the react devtools connected to your Application. 🚀
86+
87+
<hr/>
88+
89+
## Configurations
90+
91+
### API
92+
93+
The `@callstack/react-native-release-inspector` requires the user to configure their `metro.config` as shown above. This `withReactNativeReleaseInspector` receives the following arguments:
94+
95+
- `withReactNativeReleaseInspector(config, enabled)`
96+
- `config: MetroConfig`
97+
- User only need to pass the config instance from Metro
98+
- `enabled: Boolean`
99+
- Default value is false.
100+
- If true, enables profiling to work in release builds.
101+
102+
### CLI
103+
104+
The `@callstack/react-native-release-inspector` exposes a CLI `inspector` to start the instance of React DevTools.
105+
106+
It supports the following options:
107+
108+
| Option | Purpose |
109+
| --------------- | ------ |
110+
| start | kicks off the instance of React DevTools |
111+
| help or -h | prints how to use the CLI |
112+
113+
Sample Usages:
114+
115+
```bash
116+
yarn inspector start
117+
yarn inspector help
118+
yarn inspector -h
119+
```
120+
<hr/>
25121

26122
## Contributing
27123

28124
- [Development workflow](CONTRIBUTING.md#development-workflow)
29125
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
30126
- [Code of conduct](CODE_OF_CONDUCT.md)
31127

32-
## License
128+
## Made with ❤️ at Callstack
33129

34-
MIT
130+
**react-native-release-inspector** is an open source project and will always remain free to use. If you think it's cool, please star it 🌟.
131+
132+
[Callstack](https://www.callstack.com/) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi!
35133

36134
---
37135

38136
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
137+
138+
## License
139+
140+
MIT
141+
142+
[license-badge]: https://img.shields.io/npm/l/react-native-release-inspector?style=for-the-badge
143+
[license]: https://github.com/callstackincubator/react-native-release-inspector/blob/main/LICENSE
144+
[npm-downloads-badge]: https://img.shields.io/npm/dm/react-native-release-inspector?style=for-the-badge
145+
[npm-downloads]: https://www.npmjs.com/package/react-native-release-inspector
146+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
147+
[prs-welcome]: https://github.com/callstackincubator/react-native-release-inspector

apps/example/ios/Podfile.lock

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,75 @@ PODS:
13621362
- React-RCTFBReactNativeSpec
13631363
- ReactCommon/turbomodule/core
13641364
- ReactNativeDependencies
1365+
- react-native-safe-area-context (5.8.0):
1366+
- hermes-engine
1367+
- RCTRequired
1368+
- RCTTypeSafety
1369+
- React-Core
1370+
- React-Core-prebuilt
1371+
- React-debug
1372+
- React-Fabric
1373+
- React-featureflags
1374+
- React-graphics
1375+
- React-ImageManager
1376+
- React-jsi
1377+
- react-native-safe-area-context/common (= 5.8.0)
1378+
- react-native-safe-area-context/fabric (= 5.8.0)
1379+
- React-NativeModulesApple
1380+
- React-RCTFabric
1381+
- React-renderercss
1382+
- React-rendererdebug
1383+
- React-utils
1384+
- ReactCodegen
1385+
- ReactCommon/turbomodule/bridging
1386+
- ReactCommon/turbomodule/core
1387+
- ReactNativeDependencies
1388+
- Yoga
1389+
- react-native-safe-area-context/common (5.8.0):
1390+
- hermes-engine
1391+
- RCTRequired
1392+
- RCTTypeSafety
1393+
- React-Core
1394+
- React-Core-prebuilt
1395+
- React-debug
1396+
- React-Fabric
1397+
- React-featureflags
1398+
- React-graphics
1399+
- React-ImageManager
1400+
- React-jsi
1401+
- React-NativeModulesApple
1402+
- React-RCTFabric
1403+
- React-renderercss
1404+
- React-rendererdebug
1405+
- React-utils
1406+
- ReactCodegen
1407+
- ReactCommon/turbomodule/bridging
1408+
- ReactCommon/turbomodule/core
1409+
- ReactNativeDependencies
1410+
- Yoga
1411+
- react-native-safe-area-context/fabric (5.8.0):
1412+
- hermes-engine
1413+
- RCTRequired
1414+
- RCTTypeSafety
1415+
- React-Core
1416+
- React-Core-prebuilt
1417+
- React-debug
1418+
- React-Fabric
1419+
- React-featureflags
1420+
- React-graphics
1421+
- React-ImageManager
1422+
- React-jsi
1423+
- react-native-safe-area-context/common
1424+
- React-NativeModulesApple
1425+
- React-RCTFabric
1426+
- React-renderercss
1427+
- React-rendererdebug
1428+
- React-utils
1429+
- ReactCodegen
1430+
- ReactCommon/turbomodule/bridging
1431+
- ReactCommon/turbomodule/core
1432+
- ReactNativeDependencies
1433+
- Yoga
13651434
- React-NativeModulesApple (0.85.0):
13661435
- hermes-engine
13671436
- React-callinvoker
@@ -1747,6 +1816,53 @@ PODS:
17471816
- React-utils (= 0.85.0)
17481817
- ReactNativeDependencies
17491818
- ReactNativeDependencies (0.85.0)
1819+
- RNScreens (4.25.1):
1820+
- hermes-engine
1821+
- RCTRequired
1822+
- RCTTypeSafety
1823+
- React-Core
1824+
- React-Core-prebuilt
1825+
- React-debug
1826+
- React-Fabric
1827+
- React-featureflags
1828+
- React-graphics
1829+
- React-ImageManager
1830+
- React-jsi
1831+
- React-NativeModulesApple
1832+
- React-RCTFabric
1833+
- React-RCTImage
1834+
- React-renderercss
1835+
- React-rendererdebug
1836+
- React-utils
1837+
- ReactCodegen
1838+
- ReactCommon/turbomodule/bridging
1839+
- ReactCommon/turbomodule/core
1840+
- ReactNativeDependencies
1841+
- RNScreens/common (= 4.25.1)
1842+
- Yoga
1843+
- RNScreens/common (4.25.1):
1844+
- hermes-engine
1845+
- RCTRequired
1846+
- RCTTypeSafety
1847+
- React-Core
1848+
- React-Core-prebuilt
1849+
- React-debug
1850+
- React-Fabric
1851+
- React-featureflags
1852+
- React-graphics
1853+
- React-ImageManager
1854+
- React-jsi
1855+
- React-NativeModulesApple
1856+
- React-RCTFabric
1857+
- React-RCTImage
1858+
- React-renderercss
1859+
- React-rendererdebug
1860+
- React-utils
1861+
- ReactCodegen
1862+
- ReactCommon/turbomodule/bridging
1863+
- ReactCommon/turbomodule/core
1864+
- ReactNativeDependencies
1865+
- Yoga
17501866
- Yoga (0.0.0)
17511867

17521868
DEPENDENCIES:
@@ -1789,6 +1905,7 @@ DEPENDENCIES:
17891905
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
17901906
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
17911907
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
1908+
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
17921909
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
17931910
- React-networking (from `../node_modules/react-native/ReactCommon/react/networking`)
17941911
- React-oscompat (from `../node_modules/react-native/ReactCommon/oscompat`)
@@ -1823,6 +1940,7 @@ DEPENDENCIES:
18231940
- ReactCodegen (from `build/generated/ios/ReactCodegen`)
18241941
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
18251942
- ReactNativeDependencies (from `../node_modules/react-native/third-party-podspecs/ReactNativeDependencies.podspec`)
1943+
- RNScreens (from `../node_modules/react-native-screens`)
18261944
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
18271945

18281946
EXTERNAL SOURCES:
@@ -1903,6 +2021,8 @@ EXTERNAL SOURCES:
19032021
:path: "../node_modules/react-native/ReactCommon"
19042022
React-microtasksnativemodule:
19052023
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
2024+
react-native-safe-area-context:
2025+
:path: "../node_modules/react-native-safe-area-context"
19062026
React-NativeModulesApple:
19072027
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
19082028
React-networking:
@@ -1971,6 +2091,8 @@ EXTERNAL SOURCES:
19712091
:path: "../node_modules/react-native/ReactCommon"
19722092
ReactNativeDependencies:
19732093
:podspec: "../node_modules/react-native/third-party-podspecs/ReactNativeDependencies.podspec"
2094+
RNScreens:
2095+
:path: "../node_modules/react-native-screens"
19742096
Yoga:
19752097
:path: "../node_modules/react-native/ReactCommon/yoga"
19762098

@@ -2013,6 +2135,7 @@ SPEC CHECKSUMS:
20132135
React-logger: ee47d5f3b59a46a006c65038ed5d0b1143e37510
20142136
React-Mapbuffer: 7f8bfbe3fcb2203db4ccb3975414af8cabe4bcd0
20152137
React-microtasksnativemodule: ca1f33f7c98b76d923f550d39631eb4e05fa9aec
2138+
react-native-safe-area-context: fb5c8ee9f6dd62ef710611b3d370c501f42a4ac0
20162139
React-NativeModulesApple: 9c1f8815ebd72cc1c75587fe588513f6dd9cb708
20172140
React-networking: 8f75f882c6794e91e28b458b5bc1461034098c80
20182141
React-oscompat: 5361d0fa7905ba1c3b3c5e7c464d6be9d2d85f4b
@@ -2047,6 +2170,7 @@ SPEC CHECKSUMS:
20472170
ReactCodegen: b3184a229afd01e7f8058dd81b805b843caa2bf9
20482171
ReactCommon: fe2a3af8975e63efa60f95fca8c34dc85deee360
20492172
ReactNativeDependencies: e791424e30706256b549eaf97aaca169ca170c2b
2173+
RNScreens: 75d04ea58bd7a8e8ac60b7968d0382aa71631a7d
20502174
Yoga: e83c3121d079541e69f3c5c623faaaf933fb5812
20512175

20522176
PODFILE CHECKSUM: 4a21655142e46a595eeb8a1e91de752c15ab3838

apps/example/ios/ReleaseInspectorExample.xcodeproj/xcshareddata/xcschemes/ReleaseInspectorExample.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</Testables>
4242
</TestAction>
4343
<LaunchAction
44-
buildConfiguration = "Release"
44+
buildConfiguration = "Debug"
4545
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4646
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4747
launchStyle = "0"

apps/example/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
},
1212
"dependencies": {
1313
"@callstack/react-native-release-inspector": "workspace:*",
14+
"@react-navigation/native": "^7.2.4",
15+
"@react-navigation/native-stack": "^7.15.1",
1416
"react": "19.2.3",
15-
"react-native": "0.85.0"
17+
"react-native": "0.85.0",
18+
"react-native-safe-area-context": "^5.8.0",
19+
"react-native-screens": "^4.25.1"
1620
},
1721
"devDependencies": {
1822
"@babel/core": "^7.25.2",

apps/example/src/App.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import { Text, View, StyleSheet } from 'react-native';
1+
import { Navigation } from './navigation';
22

33
export default function App() {
4-
return (
5-
<View style={styles.container}>
6-
<Text>Result: 3</Text>
7-
</View>
8-
);
9-
}
10-
11-
const styles = StyleSheet.create({
12-
container: {
13-
flex: 1,
14-
alignItems: 'center',
15-
justifyContent: 'center',
16-
},
17-
});
4+
return <Navigation />;
5+
}

0 commit comments

Comments
 (0)