-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associate Apollo context with React.createContext
(instead of using a local WeakMap
) again
#8798
Associate Apollo context with React.createContext
(instead of using a local WeakMap
) again
#8798
Conversation
26810b3
to
b9c3f0a
Compare
b9c3f0a
to
11f485e
Compare
Should fix #8790, by allowing multiple copies of `@apollo/client` (uncommon) to share the same `React.createContext[contextKey]` object.
11f485e
to
d1b8d0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @benjamn!
@benjamn @hwillson My vue 2.6 projects are failing to run/build after upgrading the apollo client dependency to 3.4.12. Log:
Reverting to 3.4.11 fixes the problem. Thanks. |
@@ -1,4 +1,5 @@ | |||
import { Observable } from "./Observable"; | |||
import { canUseSymbol } from ".."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems to have caused a number of problems, hopefully all fixed by #8817.
@ruben-nogueira Please try |
@benjamn it's okay. Thanks again. 👍 |
Should fix #8790, by allowing multiple copies of
@apollo/client
(uncommon) to share the sameReact.createContext[contextKey]
object.A lot has changed since #7371, but I am not worried about
React.createContext
being undefined, because (in this module,ApolloContext.ts
), theReact
object is now a namespace object (thanks toimport * as React from 'react'
), and we callReact.createContext
unconditionally withingetApolloContext
already, soReact.createContext
must be defined whengetApolloContext
is called, or this code would be totally broken.This implementation uses
React.createContext[contextKey]
instead ofReact[contextKey]
(as in #7371) because theReact
namespace object is likely frozen/non-extensible, whereasReact.createContext
is an ordinary function object.