What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABFMBANQEMAbKBXAXlwAoBKGgPn0IFkEBbCOxl3ABYATABpcAbQC6DANwAdDOix4AFhAgBrMDVzA2xcpVwBfBRkXKcuAGIkAlmR21+1VsEW5cVvPoKGKKhNddS0wcy8fXAA3Iypaf1JAxgjcGARsWAxcAB4wAAcSDGZgWMCTHIB6AqLmRRNFS0xrAHUIGG1dV3dPb2bfAyTKZBjTEI1tVKiy41polN70zJhsvMLi0riK6vW6jAaMEFE0TAAzewBzFBB7Lnz2vGwAT3yqfQAFCgv7DAB5fOw9maY1OMAgXFwAHIAEYkaEIMgAWnyXx+iPSJDg2ER6DujgQMEqABN7DhIeZFHQPPtcGASICwOcEDpPlBvn8AUCsHIjuB1AB3ACSGGwBIw5DAKFOEoQJiAA
Repro steps
The React Compiler doesn't correctly flag improper hook usage, when using a "hooks provider".
Although the hook is always called, React Compiler fails with the following message:
Hooks may not be referenced as normal values, they must be called.
It seems the fact that the hook variable name starts with use_ is causing the compiler assume its usage.
const useValue = () => useMemo(() => 42, []);
const hooks = { useValue };
const Fails = () => {
const { useValue } = hooks;
const value = useValue();
// ^^^^^^^^ Hooks may not be referenced as normal values, they must be called.
return <span>{value}</span>
}
const Works = () => {
const { useValue: v } = hooks;
const value = v(); // works as expected
return <span>{value}</span>
}
How often does this bug happen?
Every time
What version of React are you using?
19.2.1
What version of React Compiler are you using?
1.0.0
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABFMBANQEMAbKBXAXlwAoBKGgPn0IFkEBbCOxl3ABYATABpcAbQC6DANwAdDOix4AFhAgBrMDVzA2xcpVwBfBRkXKcuAGIkAlmR21+1VsEW5cVvPoKGKKhNddS0wcy8fXAA3Iypaf1JAxgjcGARsWAxcAB4wAAcSDGZgWMCTHIB6AqLmRRNFS0xrAHUIGG1dV3dPb2bfAyTKZBjTEI1tVKiy41polN70zJhsvMLi0riK6vW6jAaMEFE0TAAzewBzFBB7Lnz2vGwAT3yqfQAFCgv7DAB5fOw9maY1OMAgXFwAHIAEYkaEIMgAWnyXx+iPSJDg2ER6DujgQMEqABN7DhIeZFHQPPtcGASICwOcEDpPlBvn8AUCsHIjuB1AB3ACSGGwBIw5DAKFOEoQJiAA
Repro steps
The React Compiler doesn't correctly flag improper hook usage, when using a "hooks provider".
Although the hook is always called, React Compiler fails with the following message:
It seems the fact that the hook variable name starts with
use_is causing the compiler assume its usage.How often does this bug happen?
Every time
What version of React are you using?
19.2.1
What version of React Compiler are you using?
1.0.0