Skip to content

Commit b712644

Browse files
authored
Reduce react-devtools-custom overhead by deferring hook inspection
inspectHooksOfFiber is too expensive for this use case. On frequently updating components, it can become slow enough to freeze the browser. Revert hook change detection to the pre-react#35123 behavior. Then defer parsing hook metadata, such as hook names, until after the commit completes, and add caching so hook inspection runs at most once per fiber whenever possible. For now, special handling is only implemented for SyncExternalStore, Transition, ActionState, and FormState.
2 parents 831c764 + 21ed002 commit b712644

10 files changed

Lines changed: 1585 additions & 2016 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Create GitHub Release on Commit
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create_release:
13+
name: Create versioned release from package.json
14+
if: github.event.deleted == false
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Create GitHub release
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
const {owner, repo} = context.repo;
22+
const branch = context.ref.replace('refs/heads/', '');
23+
const sha = context.sha;
24+
const packagePath = 'packages/react-devtools-custom/package.json';
25+
const packageFile = await github.rest.repos.getContent({
26+
owner,
27+
repo,
28+
path: packagePath,
29+
ref: sha,
30+
});
31+
32+
if (Array.isArray(packageFile.data) || !packageFile.data.content) {
33+
throw new Error(`Could not read ${packagePath} from commit ${sha}.`);
34+
}
35+
36+
const packageJson = JSON.parse(
37+
Buffer.from(packageFile.data.content, 'base64').toString('utf8')
38+
);
39+
40+
if (!packageJson.name || !packageJson.version) {
41+
throw new Error(
42+
`${packagePath} must include both "name" and "version".`
43+
);
44+
}
45+
46+
const releaseName = `${packageJson.name}-v${packageJson.version}`;
47+
const tagName = releaseName;
48+
const tagRef = `refs/tags/${tagName}`;
49+
const commitUrl = `${context.serverUrl}/${owner}/${repo}/commit/${sha}`;
50+
const commitMessage = context.payload.head_commit?.message || '';
51+
const releaseBody = [
52+
`Branch: ${branch}`,
53+
`Commit: ${sha}`,
54+
`Package: ${packageJson.name}`,
55+
`Version: ${packageJson.version}`,
56+
'',
57+
commitMessage,
58+
'',
59+
commitUrl,
60+
].join('\n');
61+
62+
try {
63+
await github.rest.git.createRef({
64+
owner,
65+
repo,
66+
ref: tagRef,
67+
sha,
68+
});
69+
core.info(`Created tag ${tagName} for ${sha}.`);
70+
} catch (error) {
71+
if (error.status !== 422) {
72+
throw error;
73+
}
74+
75+
core.info(`Tag ${tagName} already exists; continuing.`);
76+
}
77+
78+
try {
79+
await github.rest.repos.createRelease({
80+
owner,
81+
repo,
82+
tag_name: tagName,
83+
target_commitish: sha,
84+
name: releaseName,
85+
body: releaseBody,
86+
draft: false,
87+
prerelease: false,
88+
make_latest: 'false',
89+
});
90+
core.info(`Created release ${tagName}.`);
91+
} catch (error) {
92+
if (error.status !== 422) {
93+
throw error;
94+
}
95+
96+
core.info(`Release ${tagName} already exists; skipping.`);
97+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ chrome-user-data
2828
.claude/*.local.*
2929

3030
packages/react-devtools-core/dist
31+
packages/react-devtools-custom/dist
3132
packages/react-devtools-extensions/chrome/build
3233
packages/react-devtools-extensions/chrome/*.crx
3334
packages/react-devtools-extensions/chrome/*.pem
@@ -40,4 +41,3 @@ packages/react-devtools-fusebox/dist
4041
packages/react-devtools-inline/dist
4142
packages/react-devtools-shell/dist
4243
packages/react-devtools-timeline/dist
43-

0 commit comments

Comments
 (0)