Last active
March 6, 2018 12:59
-
-
Save nilshartmann/8b7ffb6429708dfae19bf6b4b1b5dfd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "with-apollo-bug", | |
"version": "1.0.0", | |
"dependencies": { | |
"@types/classnames": "^2.2.3", | |
"@types/prop-types": "^15.5.2", | |
"@types/react": "^16.0.31", | |
"@types/react-dom": "^16.0.3", | |
"apollo-boost": "^0.1.1", | |
"babel-polyfill": "^6.26.0", | |
"graphql": "^0.13.1", | |
"react": "^16.1.1", | |
"react-apollo": "2.1.0-beta.2", | |
"react-dom": "^16.1.1", | |
}, | |
"devDependencies": { | |
"awesome-typescript-loader": "^3.4.1", | |
"typescript": "^2.7.2", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import { ApolloClient } from "apollo-client"; | |
import { HttpLink } from "apollo-link-http"; | |
import { InMemoryCache } from "apollo-cache-inmemory"; | |
import { ApolloProvider, withApollo } from "react-apollo"; | |
const apolloClient = new ApolloClient({ | |
link: new HttpLink(), | |
cache: new InMemoryCache() | |
}); | |
interface MyAppProps { | |
client: ApolloClient<any>; | |
} | |
function MyApp(props: MyAppProps) { | |
props.client.resetStore(); // OK, WORKS! | |
return <div>Lorem Ipsum</div>; | |
} | |
// does NOT work: | |
const MyAppWithApollo = withApollo(MyApp); | |
// does work: | |
// const MyAppWithApollo = withApollo<{}, {}>(MyApp); | |
ReactDOM.render( | |
<ApolloProvider client={apolloClient}> | |
{/* | |
Without type params in the withApollo-Call above this does not work: | |
...Property 'client' is missing in type '{}'.... | |
*/} | |
<MyAppWithApollo /> | |
</ApolloProvider>, | |
document.getElementById("mount") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment