Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure forwardRef's ReactJsComponentFactoryProxy always uses List children #269

Merged
merged 3 commits into from
Aug 3, 2020

Conversation

joebingham-wk
Copy link
Collaborator

Motivation

While adding onto the forwardRef API in OverReact, it was discovered that consuming props.children in the forwardRef HOC threw a type error because the children weren't guaranteed to be a List as expected.

Changes

  • Utilize the alwaysReturnChildrenAsList flag on ReactJsComponentFactoryProxy to ensure children are always wrapped in a List
  • Add tests

@joebingham-wk joebingham-wk changed the base branch from master to 5.5.0-wip July 31, 2020 19:21
Copy link
Collaborator

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

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

+1

var ForwardRefTestComponent = forwardRef((props, ref) {
// Extra type checking since JS refs being passed through
// aren't caught by built-in type checking.
expect(ref, isA<Ref>());
Copy link
Collaborator

Choose a reason for hiding this comment

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

These expects get called in the component zone, not the test zone, so if they throw they won't fail the test or show up in the console output. I think they actually throw right now with "expect may only be called within tests", but the error is swallowed.

Can we move these expects out of the render call-stack? (e.g., by storing ref/children in closure variables or something).

Copy link
Collaborator

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

+10

@greglittlefield-wf greglittlefield-wf merged commit 5e4c3c2 into 5.5.0-wip Aug 3, 2020
@joebingham-wk joebingham-wk deleted the forwardRef-list-children branch August 3, 2020 19:26
@aaronlademann-wf aaronlademann-wf added this to the 5.5.0 milestone Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants