-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Enhance dev warnings for forwardRef render function (#13627) #13636
Conversation
- 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.
Details of bundled changes.Comparing: dde0645...5c832cc schedule
Generated by 🚫 dangerJS |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
packages/react/src/forwardRef.js
Outdated
'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', |
There was a problem hiding this comment.
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.
Thanks |
Thank you! I am happy to contribute 😄 |
…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
…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
arguments object.
Solves #13627