react icon indicating copy to clipboard operation
react copied to clipboard

[React 19] Can we get top-level funciton imports without being prefixed with `use` to be more semantic?

Open Nefcanto opened this issue 9 months ago • 2 comments

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.

Nefcanto avatar May 13 '24 10:05 Nefcanto

@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.

Nefcanto avatar May 14 '24 04:05 Nefcanto

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

rickhanlonii avatar May 19 '24 02:05 rickhanlonii