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

(fix) - correct Context types for useContext#3018

Merged
hwillson merged 7 commits intoapollographql:masterfrom
JoviDeCroock:fix/contextTypes
May 28, 2019
Merged

(fix) - correct Context types for useContext#3018
hwillson merged 7 commits intoapollographql:masterfrom
JoviDeCroock:fix/contextTypes

Conversation

@JoviDeCroock
Copy link
Copy Markdown
Contributor

@JoviDeCroock JoviDeCroock commented May 7, 2019

Fixes: #3016

The type for useContext can't be derived like this, it's better to check for react.createContext to exist in Consumer then to derive the type like this.

Now useContext(ApolloContext) does not return a TS error anymore.

@JoviDeCroock JoviDeCroock changed the title fix: refactor for using useContext with TS (fix) - correct Context types for useContext May 8, 2019
Copy link
Copy Markdown
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much @JoviDeCroock!

@hwillson hwillson merged commit 028333e into apollographql:master May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS: Type of ApolloContext makes it hard to use

2 participants