Skip to content

Commit

Permalink
Merge pull request #10309 from apollographql/tb/docs-subscribetomore-…
Browse files Browse the repository at this point in the history
…useeffect

docs: Update subscribeToMore example to use React hooks
  • Loading branch information
Stephen Barlow authored Nov 22, 2022
2 parents b677e60 + 8614c70 commit e139105
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/source/data/subscriptions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,10 @@ In the example above, we pass three options to `subscribeToMore`:

Finally, in our definition of `CommentsPage`, we tell the component to `subscribeToNewComments` when it mounts:

```js
export class CommentsPage extends Component {
componentDidMount() {
this.props.subscribeToNewComments();
}
```jsx
export function CommentsPage({subscribeToNewComments}) {
useEffect(() => subscribeToNewComments(), []);
return <>...</>
}
```

Expand Down

0 comments on commit e139105

Please sign in to comment.