Skip to content

Commit

Permalink
Fix/update ApolloProvider docs (#6625)
Browse files Browse the repository at this point in the history
* remove unused ApolloProvider mdx import

* inline apollo-provider.mdx into hooks.mdx and update

This removes some instructions and updates the example code to use `@apollo/client`. The code was inlined because it is no longer shared and as a workaround for a possibly unrelated issue.
  • Loading branch information
henryqdineen authored Jul 17, 2020
1 parent 4a724ff commit e500683
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
21 changes: 0 additions & 21 deletions docs/shared/apollo-provider.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
The `ApolloProvider` component leverages [React's Context API](https://reactjs.org/docs/context.html) to make a configured Apollo Client instance available throughout a React component tree. This component can be imported directly from the `@apollo/react-common` package where it lives, or from one of the `@apollo/react-hooks`, `@apollo/react-components`, and `@apollo/react-hoc` packages.

```js
import { ApolloProvider } from '@apollo/react-hooks';
```

### Props

| Option | Type | Description |
| -------- | -------------------------- | --------------------------- |
| `client` | ApolloClient<TCache> | An `ApolloClient` instance. |

### Example

```jsx
ReactDOM.render(
<ApolloProvider client={client}>
<MyRootComponent />
</ApolloProvider>,
document.getElementById('root'),
);
```
2 changes: 0 additions & 2 deletions docs/source/api/react/hoc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ sidebar_title: 'HOC (deprecated)'
description: Deprecated React Apollo HOC API
---

import ApolloProvider from '../../../shared/apollo-provider.mdx';

> **NOTE:** React Apollo's higher order components have been deprecated. They will continue to receive bug fixes until March 2020, after which they will no longer be maintained by Apollo.
## Installation
Expand Down
24 changes: 22 additions & 2 deletions docs/source/api/react/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: Hooks
description: Apollo Client react hooks API reference
---

import ApolloProvider from '../../../shared/apollo-provider.mdx';
import QueryOptions from '../../../shared/query-options.mdx';
import QueryResult from '../../../shared/query-result.mdx';
import MutationOptions from '../../../shared/mutation-options.mdx';
Expand All @@ -17,7 +16,28 @@ Apollo Client >= 3 includes React hooks functionality out of the box. You don't

## `ApolloProvider`

<ApolloProvider />
The `ApolloProvider` component leverages [React's Context API](https://reactjs.org/docs/context.html) to make a configured Apollo Client instance available throughout a React component tree. This component can be imported directly from the `@apollo/client` package.

```js
import { ApolloProvider } from '@apollo/client';
```

### Props

| Option | Type | Description |
| -------- | -------------------------- | --------------------------- |
| `client` | ApolloClient&lt;TCache&gt; | An `ApolloClient` instance. |

### Example

```jsx
ReactDOM.render(
<ApolloProvider client={client}>
<MyRootComponent />
</ApolloProvider>,
document.getElementById('root'),
);
```

## `ApolloConsumer`

Expand Down

0 comments on commit e500683

Please sign in to comment.