Skip to content

fix: support forwardRef with out of line argument - #430

Merged
danez merged 1 commit into
reactjs:masterfrom
motiz88:non-inline-forwardref
Feb 13, 2020
Merged

fix: support forwardRef with out of line argument#430
danez merged 1 commit into
reactjs:masterfrom
motiz88:non-inline-forwardref

Conversation

@motiz88

@motiz88motiz88 commented Feb 11, 2020

Copy link
Copy Markdown
Contributor

Enables handlers that support forwardRef (defaultProps and Flow type handling) to work when the argument to forwardRef is a reference to a function defined outside of the forwardRef call:

importReactfrom'react';constComponentImpl=({ foo ='bar'},ref)=><divref={ref}>{foo}</div>;React.forwardRef(ComponentImpl);

This is achieved by reusing resolveToValue.

Note that this does not fix the rebinding case, which I intend to tackle separately:

importReactfrom'react';letComponentImpl=({ foo ='bar'},ref)=><divref={ref}>{foo}</div>;ComponentImpl=React.forwardRef(ComponentImpl);// resolveToValue resolves here :/

@danezdanez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @motiz88, nice to see you again. Thanks for the PR. lgtm

@danez
danez merged commit b5e6d97 into reactjs:masterFeb 13, 2020
@motiz88
motiz88 deleted the non-inline-forwardref branch February 13, 2020 00:37
@github-actionsgithub-actionsBot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@motiz88@danez