Skip to content

Commit 4effd46

Browse files
committed
use weakset
1 parent 1f1aaad commit 4effd46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react/src/error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function isAtLeastReact17(reactVersion: string): boolean {
1616
* Recurse through `error.cause` chain to set cause on an error.
1717
*/
1818
export function setCause(error: Error & { cause?: Error }, cause: Error): void {
19-
const seenErrors = new WeakMap<Error, boolean>();
19+
const seenErrors = new WeakSet();
2020

2121
function recurse(error: Error & { cause?: Error }, cause: Error): void {
2222
// If we've already seen the error, there is a recursive loop somewhere in the error's
@@ -25,7 +25,7 @@ export function setCause(error: Error & { cause?: Error }, cause: Error): void {
2525
return;
2626
}
2727
if (error.cause) {
28-
seenErrors.set(error, true);
28+
seenErrors.add(error);
2929
return recurse(error.cause, cause);
3030
}
3131
error.cause = cause;

0 commit comments

Comments
 (0)