|
7 | 7 | usePreventRemoveContext, |
8 | 8 | type StaticScreenProps, |
9 | 9 | } from "@react-navigation/native"; |
10 | | -import { useEffect, useLayoutEffect, useMemo, useState } from "react"; |
| 10 | +import { useEffect, useLayoutEffect, useState } from "react"; |
11 | 11 | import { View } from "react-native"; |
12 | 12 | import { useAtomValue } from "@effect/atom-react"; |
13 | 13 | import { |
@@ -171,25 +171,17 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf |
171 | 171 | const preparedBranch = prepared ? prepared.branch : initialProjectRef.branch; |
172 | 172 | const preparedWorktreePath = prepared ? prepared.worktreePath : initialProjectRef.worktreePath; |
173 | 173 | // NewTaskDraftScreen re-applies the route project (and rewrites the draft's |
174 | | - // workspace) whenever this object's identity changes. The compiler does not |
175 | | - // memoize values that cross the hooks above, so key it on its fields; |
176 | | - // otherwise every draft write re-renders into another write. |
177 | | - const preparedProjectRef = useMemo( |
178 | | - () => ({ |
179 | | - environmentId: initialProjectRef.environmentId, |
180 | | - projectId: initialProjectRef.projectId, |
181 | | - branch: preparedBranch, |
182 | | - worktreePath: preparedWorktreePath, |
183 | | - cloning: initialProjectRef.cloning, |
184 | | - }), |
185 | | - [ |
186 | | - initialProjectRef.environmentId, |
187 | | - initialProjectRef.projectId, |
188 | | - preparedBranch, |
189 | | - preparedWorktreePath, |
190 | | - initialProjectRef.cloning, |
191 | | - ], |
192 | | - ); |
| 174 | + // workspace) whenever this object's identity changes. initialProjectRef is new |
| 175 | + // every render, so read its fields first: the compiler then memoizes this |
| 176 | + // object on them, instead of on initialProjectRef. |
| 177 | + const { environmentId, projectId, cloning } = initialProjectRef; |
| 178 | + const preparedProjectRef = { |
| 179 | + environmentId, |
| 180 | + projectId, |
| 181 | + branch: preparedBranch, |
| 182 | + worktreePath: preparedWorktreePath, |
| 183 | + cloning, |
| 184 | + }; |
193 | 185 | const preparingBranch = checkoutPending || (needsPreparation && result?._tag !== "Success"); |
194 | 186 |
|
195 | 187 | if (!initialized) return null; |
|
0 commit comments