Closed
Description
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;