Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
(fix) - correct Context types for useContext (#3018)
Browse files Browse the repository at this point in the history
* fix: refactor for using useContext with TS

* fix: praect does not support .createContext

* chore: resolve code inconsistency

* refactor: the added type can be removed

* Changelog update
  • Loading branch information
JoviDeCroock authored and hwillson committed May 28, 2019
1 parent b2f3928 commit 028333e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Make sure `MockedProvider` is using the proper CJS/ESM bundle, when
referencing `ApolloProvider`. <br/>
[@jure](https://github.com/jure) in [#3029](https://github.com/apollographql/react-apollo/pull/3029).
- Adjust the `ApolloContext` definition to play a bit more nicely with
`React.createContext` types. <br/>
[@JoviDeCroock](https://github.com/JoviDeCroock) in [#3018](https://github.com/apollographql/react-apollo/pull/3018)

### Bug Fixes

Expand Down
5 changes: 2 additions & 3 deletions src/ApolloContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export interface ApolloContextValue {
operations?: Map<string, { query: DocumentNode; variables: any }>;
}

export const ApolloContext = React.createContext
? React.createContext<ApolloContextValue | undefined>(undefined)
: null;
export const ApolloContext = React.createContext &&
React.createContext<ApolloContextValue | undefined>(undefined)

0 comments on commit 028333e

Please sign in to comment.