Skip to content

Commit 593c08f

Browse files
authored
Merge pull request meshtastic#469 from danditomaso/feat/add-react-scan-debugging
feat: add react scan debugging
2 parents 8be849d + 801f8f3 commit 593c08f

File tree

5 files changed

+145
-0
lines changed

5 files changed

+145
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,42 @@ If you encounter any issues with nightly builds, please report them in our [issu
7575
## Development & Building
7676
You'll need to download the package manager used with this repo. You can install it by visiting [Bun.sh](https://bun.sh/) and following the installation instructions.
7777

78+
### Debugging
79+
80+
#### Debugging with React Scan
81+
Meshtastic Web Client has included the library [React Scan](https://github.com/aidenybai/react-scan) to help you identify and resolve render performance issues during development.
82+
83+
React's comparison-by-reference approach to props makes it easy to inadvertently cause unnecessary re-renders, especially with:
84+
85+
- Inline function callbacks (`onClick={() => handleClick()}`)
86+
- Object literals (`style={{ color: "purple" }}`)
87+
- Array literals (`items={[1, 2, 3]}`)
88+
89+
These are recreated on every render, causing child components to re-render even when nothing has actually changed.
90+
91+
Unlike React DevTools, React Scan specifically focuses on performance optimization by:
92+
93+
- Clearly distinguishing between necessary and unnecessary renders
94+
- Providing render counts for components
95+
- Highlighting slow-rendering components
96+
- Offering a dedicated performance debugging experience
97+
98+
#### Usage
99+
When experiencing slow renders, run:
100+
101+
```bash
102+
bun run dev:scan
103+
```
104+
105+
This will allow you to discover the following about your components and pages:
106+
107+
- Components with excessive re-renders
108+
- Performance bottlenecks in the render tree
109+
- Expensive hook operations
110+
- Props that change reference on every render
111+
112+
Use these insights to apply targeted optimizations like `React.memo()`, `useCallback()`, or `useMemo()` where they'll have the most impact.
113+
78114
### Building and Packaging
79115

80116
Build the project:

0 commit comments

Comments
 (0)