react
react copied to clipboard
[React 19] Can we get top-level funciton imports without being prefixed with `use` to be more semantic?
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.
@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
.
No, the use
prefix is the only way we currently have to enforce the rules of hooks.