eslint-plugin-react-hooks: 7.0.1
Steps To Reproduce
1.Create react app
2. Add this eslint-plugin-react-hooks plugin
3. Lint the next code
import { FeatureRemovalBuildTime } from '@xxx/build-time-tools/FeatureRemovalBuildTime';
import { PlatformSwitchBuildTime } from '@xxx/build-time-tools/PlatformSwitchBuildTime';
import { isMyFeature } from '@xxx/config/exporter';
import ErrorMessageMT from './ErrorMessageMT';
import ErrorMessageBase from './ErrorMessageBase';
import type { ErrorMessageProps } from './types';
const ErrorMessage = (props: ErrorMessageProps) => {
'use memo';
const ErrorMessageView = PlatformSwitchBuildTime.select({
anyMT:
FeatureRemovalBuildTime.isMyFeature && isMyFeature()
? ErrorMessageMT
: ErrorMessageBase,
default: ErrorMessageBase,
});
return <ErrorMessageView {...props} />; // Error: react-hooks/static-components
};
export default ErrorMessage;
The current behavior
Eslint will complain that ErrorMessageView was created during the render
The expected behavior
But all values inside if check are stable and valid as in this example: https://react.dev/reference/eslint-plugin-react-hooks/lints/static-components#valid
eslint-plugin-react-hooks: 7.0.1
Steps To Reproduce
1.Create react app
2. Add this
eslint-plugin-react-hooksplugin3. Lint the next code
The current behavior
Eslint will complain that
ErrorMessageViewwas created during the renderThe expected behavior
But all values inside if check are stable and valid as in this example: https://react.dev/reference/eslint-plugin-react-hooks/lints/static-components#valid