Skip to content

Commit af94b52

Browse files
Add readme example and jsdoc comments
1 parent deb1eaa commit af94b52

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# react-native-console-symbolicator
22

3-
Make all Errors logged via `console` API readable inside React Native Dev Tools.
3+
Make all Errors logged via `console` API readable inside React Native DevTools.
4+
5+
![React Native Console Symbolicator Example](./public/example.png)
6+
7+
### From
8+
9+
```
10+
Error: When reading this error in React Native DevTools, you should see the original source code location instead of the bundle.
11+
at action (http://192.168.0.129:8081/example/index.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:97154:36)
12+
```
13+
14+
### To
15+
16+
```
17+
Error: When reading this error in React Native DevTools, you should see the original source code location instead of the bundle.
18+
at action (/Users/krystofwoldrich/repos/krystofwoldrich/console-symbolicator/example/src/App.tsx:49:37)
19+
```
420

521
## Installation
622

example/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ installConsoleSymbolicator({
1414
});
1515

1616
const message =
17-
'When reading this error in React Native Dev Tools, you should see the original source code location instead of the bundle.';
17+
'When reading this error in React Native DevTools, you should see the original source code location instead of the bundle.';
1818

1919
export default function App() {
2020
const colorScheme = useColorScheme();

public/example.png

478 KB
Loading

src/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,36 @@ import parseErrorStack from 'react-native/Libraries/Core/Devtools/parseErrorStac
33

44
type ConsoleLogFunction = (...args: unknown[]) => void;
55

6+
/**
7+
* Installs a console symbolicator that will symbolicate stack traces in console
8+
* logs, making it easier to debug errors in React Native applications.
9+
*
10+
* This function should be called at the start of your application, typically
11+
* in the entry file (e.g., `_layout.tsx` or `App.tsx`).
12+
*
13+
* @param {Object} options - Configuration options for the symbolicator.
14+
* @param {boolean} [options.excludeReactNativeCoreFrames=false] - If set to `true`,
15+
* the symbolicator will drop frames from `node_modules/react-native`
16+
* package. This helps readability of the stack trace, but information
17+
* about the internal React Native Core stack is lost.
18+
*
19+
* @example
20+
* installConsoleSymbolicator({ excludeReactNativeCoreFrames: true });
21+
*/
622
export const installConsoleSymbolicator = ({
723
excludeReactNativeCoreFrames = false,
824
}: {
25+
/**
26+
* If set to `true`,
27+
* the symbolicator will drop frames from `node_modules/react-native`
28+
* package. This helps readability of the stack trace, but information
29+
* about the internal React Native Core stack is lost.
30+
*
31+
* @default false
32+
*
33+
* @example
34+
* installConsoleSymbolicator({ excludeReactNativeCoreFrames: true });
35+
*/
936
excludeReactNativeCoreFrames?: boolean;
1037
} = {}) => {
1138
if (!__DEV__) {

0 commit comments

Comments
 (0)