Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation Request] Explicit examples and/or best practices for querying from react class components #9413

Closed
kaysond opened this issue Feb 9, 2022 · 4 comments

Comments

@kaysond
Copy link

kaysond commented Feb 9, 2022

The current documentation has no mention of ReactJS class components, and this is a question that seems to come up: #7111, StackOverflow 1 Stack Overflow 2

Ok actually there is one tiny mention! In the section on typescript, there's a brief mention of Classes vs Functions which rightly points out that sometimes components depending on graphql data have state! Except the example uses @apollo/react-hoc which is deprecated.

It would be great to have something more explicit here. It seems that most people have resorted to passing the client object around and running a .query() on it directly in a lifecycle function and updating component state. That's... clunky. Obviously HOC is not the best choice.

I did notice the ApolloConsumer component docs mention that

You can think of the ApolloConsumer component as similar to the Consumer component from the React Context API.

Is there actually a Context here that can be used by the static MyClass.contextType?

Thanks!

@alessbell
Copy link
Contributor

Hi @kaysond 👋

I'm doing some housekeeping and came across this issue. While I recognize that the lack of documentation for usage within React class components has created some challenges for you and others in the past, Apollo Client's render prop and HOC APIs have been deprecated since 2020. In our upcoming 3.9 release, we've added a missing @deprecated tag in their respective docblocks so a warning about their deprecated status will appear in your IDE once you upgrade (and use TypeScript).

With that being said, I'm going to close this issue since we'd like to discourage use of these deprecated APIs and won't be fielding PRs to add this documentation. Please feel free to join our Discord where you can direct any questions about usage to the #frontend channel. Thanks!

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

@alessbell alessbell closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants