-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Enable warnings for the defaultValue prop #13360
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
Closed
raunofreiberg
wants to merge
5
commits into
facebook:master
from
raunofreiberg:defaultvalue-warnings
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8de05f8
tests: remove TODOs about warnings in ReactDOMInput-test.js
raunofreiberg e1aeb5c
fix: remove fit
raunofreiberg 4d22d81
Run prettier
raunofreiberg 5120ce3
refactor: Enable warnings for the defaultValue prop in shouldRemoveAt…
raunofreiberg 2132b74
refactor: use shouldWarnInDev boolean for reserved props warnings
raunofreiberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,12 +214,6 @@ if (__DEV__) { | |
return true; | ||
} | ||
|
||
// Now that we've validated casing, do not validate | ||
// data types for reserved props | ||
if (isReserved) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to remove this since the |
||
return true; | ||
} | ||
|
||
// Warn when a known attribute is a bad type | ||
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { | ||
warnedProperties[name] = true; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a bit odd. Maybe we shouldn’t treat it as reserved?
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.
I agree, but wouldn't we then be committing unwanted attributes to the DOM?
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.
I don’t know. You tell me what would happen :-)
Uh oh!
There was an error while loading. Please reload this page.
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.
I went ahead and uncommented
defaultValue
from the list of reserved properties and a few test suites started to fail in a similar manner (for e.g,ReactDOMServerIntegrationForms
), confirming what I was expecting.E.g.
This seems to only affect SSR, client side cases seem to pass, for e.g:
I'm not too certain nor familiar with how strict we want to be about reserved properties (committing them to the DOM is definitely out of the question, I would assume).
Maybe we can keep the attribute reserved as is, but instead add another key to
PropertyInfo
(e.g. booleanshouldWarnInDev
) to enable warnings for custom properties. This way the condition that you mentioned above would become:Also, enabling warnings for other reserved properties would be a breeze this way, IMHO :-)
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.
I've added a proof of concept commit to illustrate my approach better.