Skip to content

Commit

Permalink
Allow usage of WeakMap in React Native Hermes (#10804)
Browse files Browse the repository at this point in the history
Co-authored-by: phryneas <phryneas@users.noreply.github.com>
  • Loading branch information
phryneas and phryneas authored Dec 8, 2023
1 parent d05297d commit 221dd99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-rats-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

use WeakMap in React Native with Hermes
4 changes: 2 additions & 2 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 38576,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32352
"dist/apollo-client.min.cjs": 38589,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32365
}
4 changes: 3 additions & 1 deletion src/utilities/common/canUse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { maybe } from "../globals/index.js";

export const canUseWeakMap =
typeof WeakMap === "function" &&
maybe(() => navigator.product) !== "ReactNative";
!maybe(
() => navigator.product == "ReactNative" && !(global as any).HermesInternal
);

export const canUseWeakSet = typeof WeakSet === "function";

Expand Down

0 comments on commit 221dd99

Please sign in to comment.