Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.19 KB

File metadata and controls

47 lines (30 loc) · 1.19 KB

inferno/forward-ref-uses-ref

📝 Require all forwardRef components include a ref parameter.

💡 This rule is manually fixable by editor suggestions.

Requires that components wrapped with forwardRef must have a ref parameter. Omitting the ref argument is usually a bug, and components not using ref don't need to be wrapped by forwardRef.

See https://react.dev/reference/react/forwardRef

Rule Details

This rule checks all Inferno components using forwardRef and verifies that there is a second parameter.

The following patterns are considered warnings:

var Inferno = require('inferno');

var Component = Inferno.forwardRef((props) => (
    <div />
));

The following patterns are not considered warnings:

var Inferno = require('inferno');

var Component = Inferno.forwardRef((props, ref) => (
    <div ref={ref} />
));

var Component = Inferno.forwardRef((props, ref) => (
    <div />
));

function Component(props) {
    return <div />;
};

When not to use

If you don't want to enforce that components using forwardRef utilize the forwarded ref.