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] Can we get top-level funciton imports without being prefixed with use to be more semantic? #29048

Closed
Nefcanto opened this issue May 13, 2024 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@Nefcanto
Copy link

By convention, everyone creates hooks named useX. Then we call it to get some stuff. That stuff can include other functions:

import { useTenant } from "globalization"

const SomeComponent = () => {
     const { getCurrentTenant } = useTenant();
}

Can we get closer to this code in React 19?

import { getCurrentTenant } from "globalization"

const SomeComponent = () => {
}

That const { getCurrentTenant } = useTenant(); is boilerplate.

P.S. Because I could not find a place to discuss features, I had to send this issue here.

@eps1lon eps1lon added Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug and removed React 19 labels May 13, 2024
@MuhamedRagab
Copy link

I think it depends on getCurrentTenant logic

if you are using hooks like useMemo or anything else you have to follow react rules

else you can create your functions & export and import them easily in anywhere

@Nefcanto
Copy link
Author

@MuhamedRagab, we should follow React rules. I'm proposing that we make rules more semantic. A function that gets something is better to be named get. It should not be called use, even if it's using useMemo.

@rickhanlonii
Copy link
Member

No, the use prefix is the only way we currently have to enforce the rules of hooks.

@rickhanlonii rickhanlonii closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants