react-hooks/gating
eslint-plugin-react-hooks
import reactHooks from "eslint-plugin-react-hooks";
export default [
{
plugins: { "react-hooks": reactHooks },
rules: {
"react-hooks/gating": "error",
},
},
];module.exports = {
plugins: [
['babel-plugin-react-compiler', {
gating: {
importSpecifierName: '__experimental_useCompiler'
// Missing 'source' field
}
}]
]
};module.exports = {
plugins: [
['babel-plugin-react-compiler', {
gating: '__experimental_useCompiler' // Should be object
}]
]
};module.exports = {
plugins: [
['babel-plugin-react-compiler', {
gating: {
importSpecifierName: 'isCompilerEnabled', // exported function name
source: 'featureFlags' // module name
}
}]
]
};
// featureFlags.js
export function isCompilerEnabled() {
// ...
}module.exports = {
plugins: [
['babel-plugin-react-compiler', {
// No gating field - compiles all components
}]
]
};Examples from the ESLint documentation.
react-hooks/gating
eslint-plugin-react-hooks
import reactHooks from "eslint-plugin-react-hooks";
export default [
{
plugins: { "react-hooks": reactHooks },
rules: {
"react-hooks/gating": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Validates usage of the useMemo() hook against common mistakes. See useMemo() docs for more information.
Validates against syntax that we do not plan to support in React Compiler
Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering
Validates against setting state during render, which can trigger additional renders and potential infinite render loops
Validates against calling setState synchronously in an effect. This can indicate non-local derived data, a derived event pattern, or improper external data synchronization.