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

Apollo Client 3.9 causes linting error to be thrown when using refetch #11554

Closed
strmer15 opened this issue Feb 1, 2024 · 9 comments · Fixed by #11558 or #11561
Closed

Apollo Client 3.9 causes linting error to be thrown when using refetch #11554

strmer15 opened this issue Feb 1, 2024 · 9 comments · Fixed by #11558 or #11561

Comments

@strmer15
Copy link

strmer15 commented Feb 1, 2024

Issue Description

After updating to @apollo/client 3.9, our linter now complains about uses of refetch from the useQuery hook:

Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead  @typescript-eslint/unbound-method

I tried with @apollo/client 3.8.10 and verified that this does not happen.

Link to Reproduction

https://github.com/strmer15/apollo-client-typescript-lint-error

Reproduction Steps

Clone the repository at https://github.com/strmer15/apollo-client-typescript-lint-error

Run npm install

Run npm run lint

You should get:

apollo-client-typescript-lint-error/src/CountryList.tsx
  23:33  error  Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead  @typescript-eslint/unbound-method

✖ 1 problem (1 error, 0 warnings)

@apollo/client version

3.9.2

@alessbell
Copy link
Member

Hi @strmer15 👋

Thanks for the reproduction. @efstathiosntonas mentioned this on #11543 which was resolved (tagging in case they want to watch this issue 🙂), but we didn't have a reproduction for the linter error yet. Appreciate you opening it, taking a look.

@gizmooo
Copy link

gizmooo commented Feb 3, 2024

This means for me too

image

@alessbell
Copy link
Member

Thanks for the additional info! We should have a fix out in the next day or two via #11558.

@alessbell alessbell self-assigned this Feb 5, 2024
Copy link
Contributor

github-actions bot commented Feb 5, 2024

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
Copy link
Member

The fix has been released in v3.9.3.

@IanCStewart
Copy link

IanCStewart commented Feb 12, 2024

I'm afraid this linting error is also present for the fetchMore function. I'm on the latest version 3.9.4.

Image 12-02-2024 at 11 10

Would you like me to write a new issue or should we reopen this issue?

@alessbell
Copy link
Member

@IanCStewart I am not able to reproduce that with v3.9.6. Try removing your node_modules and reinstalling. If it persists, can you please open a new issue with a reproduction there?

@Darex1991
Copy link

I had same bug, removing and reinstalling helped :)

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 Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.