Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```bash
git clone https://github.com/aidenybai/react-scan.git
cd react-scan
corepack enable
pnpm install
```

Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"editor.colorDecorators": true,
"[css]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
12 changes: 10 additions & 2 deletions packages/scan/src/core/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ export interface Change {
export type Category = 'commit' | 'unstable' | 'unnecessary';

export interface Render {
phase: string;
// TODO: use type exported from bippy instead.
phase: 'mount' | 'update' | 'unmount';
componentName: string | null;
time: number | null;
count: number;
/**
* Whether the re-render occurred on a component wrapped with `React.memo()`.
*/
forget: boolean;
changes: Array<Change> | null;
/**
* Determine if the render is unnecessary.
* Only sampling 5% of the renders to avoid performance impact.
* Otherwise, it will be `null`.
*/
unnecessary: boolean | null;
didCommit: boolean;
fps: number;
Expand Down Expand Up @@ -165,7 +174,6 @@ export const getPropsChanges = (fiber: Fiber) => {
const prevProps = fiber.alternate?.memoizedProps || {};
const nextProps = fiber.memoizedProps || {};


const allKeys = new Set([
...Object.keys(prevProps),
...Object.keys(nextProps),
Expand Down