Skip to content

Fails to Recognize React.forwardRef #267

Closed
@yungsters

Description

@yungsters

Currently, components defined using React.forwardRef (documentation) are not recognized as components with props.

Take the following as an example:

type Props = $ReadOnly<{|
  color?: ?string,
|}>;

const ColoredView = React.forwardRef((props: Props, ref) => (
  <View style={{backgroundColor: props.color}} />
));

ColoredView.displayName = 'ColoredView';

module.exports = ColoredView;

The workaround for now is:

type Props = $ReadOnly<{|
  color?: ?string,
|}>;

const ColoredView = (props: Props, ref) => (
  <View style={{backgroundColor: props.color}} />
);

const ColoredViewWithRefForwarding = React.forwardRef(ColoredView);

ColoredViewWithRefForwarding.displayName = 'ColoredView';

module.exports = ColoredViewWithRefForwarding;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions