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

Enhance dev warnings for forwardRef render function (#13627) #13636

Merged
merged 3 commits into from Sep 13, 2018
Merged

Enhance dev warnings for forwardRef render function (#13627) #13636

merged 3 commits into from Sep 13, 2018

Conversation

andresroberto
Copy link
Contributor

  • For 0 parameters: Do not warn because it may be due to usage of the
    arguments object.
  • For 1 parameter: Warn about missing the 'ref' parameter.
  • For 2 parameters: This is the ideal. Do not warn.
  • For more than 2 parameters: Warn about undefined parameters.

Solves #13627

- For 0 parameters: Do not warn because it may be due to usage of the
  arguments object.

- For 1 parameter: Warn about missing the 'ref' parameter.

- For 2 parameters: This is the ideal. Do not warn.

- For more than 2 parameters: Warn about undefined parameters.
@sizebot
Copy link

sizebot commented Sep 13, 2018

Details of bundled changes.

Comparing: dde0645...5c832cc

schedule

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
schedule.development.js n/a n/a 0 B 19.17 KB 0 B 5.74 KB UMD_DEV
schedule.production.min.js n/a n/a 0 B 3.16 KB 0 B 1.53 KB UMD_PROD

Generated by 🚫 dangerJS

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

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

Small nits

return null;
}
it('should not warn if the render function provided does not use any parameter', () => {
const arityOfZero = () => null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this more realistic? Such as a real pass through wrapper. Otherwise intent is not clear.

'forwardRef render functions accept exactly two parameters: props and ref. %s',
render.length === 1
? 'Did you forget to use the ref parameter?'
: 'Any additional parameter will be undefined',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add period to the sentence.

@gaearon gaearon merged commit ecbf7af into facebook:master Sep 13, 2018
@gaearon
Copy link
Collaborator

gaearon commented Sep 13, 2018

Thanks

@andresroberto
Copy link
Contributor Author

Thank you! I am happy to contribute 😄

@gaearon gaearon mentioned this pull request Sep 13, 2018
Simek pushed a commit to Simek/react that referenced this pull request Oct 25, 2018
…acebook#13636)

* Enhance dev warnings for forwardRef render function

- For 0 parameters: Do not warn because it may be due to usage of the
  arguments object.

- For 1 parameter: Warn about missing the 'ref' parameter.

- For 2 parameters: This is the ideal. Do not warn.

- For more than 2 parameters: Warn about undefined parameters.

* Make test cases for forwardRef warnings more realistic

* Add period to warning sentence
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
…acebook#13636)

* Enhance dev warnings for forwardRef render function

- For 0 parameters: Do not warn because it may be due to usage of the
  arguments object.

- For 1 parameter: Warn about missing the 'ref' parameter.

- For 2 parameters: This is the ideal. Do not warn.

- For more than 2 parameters: Warn about undefined parameters.

* Make test cases for forwardRef warnings more realistic

* Add period to warning sentence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants