no-forward-ref
🔧 This rule is automatically fixable by the --fix
CLI option.
Rule category
Restriction.
What it does
Disallows using React.forwardRef
.
Why is this bad?
In React 19, forwardRef
is no longer necessary. Pass ref
as a prop instead.
forwardRef
will deprecated in a future release. Learn more here.
Examples
Failing
import { forwardRef } from 'react';
const MyInput = forwardRef(function MyInput(props, ref) {
// ...
});
Passing
function MyInput({ ref, ...props }) {
// ...
}