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

[React 19]: eslint-plugin-react-compiler gives false positive if hook takes generics #29062

Closed
SimenB opened this issue May 15, 2024 · 5 comments
Labels

Comments

@SimenB
Copy link
Contributor

SimenB commented May 15, 2024

Summary

(Not sure if this should be filed under React 19?)

The following code triggers Hooks may not be referenced as normal values, they must be called. See https://react.dev/reference/rules/react-calls-components-and-hooks#never-pass-around-hooks-as-regular-values

interface Data {}

function useHello() {
  const queryClient = useQueryClient();

  return useMutation<Data>({});
}

(useQueryClient and useMutation coming from @tanstack/react-query, fwiw)

Either removing the <Data> generic, or the preceding useQueryClient resolves the error.

This is using eslint-plugin-react-compiler@0.0.0-experimental-e04a001-20240515


Anyways, I'm super excited that you've finally open sourced this, and look forward to using it!

(I do wonder why pretty-format@24 is used in the babel plugin tho 👀 very old!)

@zolotoygagash

This comment has been minimized.

@josephsavona
Copy link
Contributor

josephsavona commented May 15, 2024

Thanks for posting this, this looks like an issue with which parser we use for TS code in the linter.

@NMinhNguyen
Copy link
Contributor

I can confirm that #29081 appears to have fixed this issue :)

@poteto
Copy link
Member

poteto commented May 16, 2024

yep this was just fixed in #29081, thanks for reporting!

@poteto poteto closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@poteto @SimenB @NMinhNguyen @josephsavona @zolotoygagash and others