-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
createClass + PropTypes + checkPropTypes warnings #9399
Conversation
2b2237f
to
5006ec8
Compare
Should be ready for review, @acdlite |
"Fixed several createClass references in fixtures" lgtm - reviewing the other change now. |
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.
Reviewed "Added getters" and "Fixed rollup" only. I don't think I fully understand how everything fits together but trust that you do if my questions don't make you unsure. :)
package.json
Outdated
@@ -95,6 +93,10 @@ | |||
"node": "4.x || 5.x || 6.x || 7.x", | |||
"npm": "2.x || 3.x || 4.x" | |||
}, | |||
"dependencies": { |
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.
Why did you move these? I think dev should be fine. This package.json is only used for development; we have others for the npm packages that get released.
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.
D'oh! Habit. I'll undo this change and update the packages/*/package.json
files instead 😄
externals: [ | ||
'create-react-class/factory', | ||
'prop-types', | ||
'prop-types/checkPropTypes', |
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.
Does only isomorphic use checkPropTypes like this? I guess I would have thought that context type checking does too.
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.
DOM does check too but it uses React.checkPropTypes
. Rollup also only complained about the externals reference for isomorphic.
src/isomorphic/React.js
Outdated
Object.defineProperty(React, 'PropTypes', { | ||
get() { | ||
warning( | ||
didWarnPropTypesDeprecated, |
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.
nit: inconsistent naming with this and warnedForCreateClass
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.
👍
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.
Let's add something like "it will be removed completely in React 16"
Also, maybe we could make this warning and the one for React.createClass
more consistent.
scripts/rollup/modules.js
Outdated
@@ -52,6 +52,17 @@ const devOnlyFilesToStubOut = [ | |||
"'ReactTestUtils'", | |||
]; | |||
|
|||
// Ordering of these imports is important; | |||
// The default import must follow deep imports or Rollup breaks. |
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.
Why does Rollup break? (This seems brittle.)
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 gave an example below (in the comments) of what it maps the requires to but I'll update it to be a bit more explicit. Basically if it partial-matches one of the keys (eg prop-types/checkPropTypes
matches prop-types
) then it stops searching and uses a path like prop-types/index.js/checkPropTypes.js
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.
Doesn't this mean that the replacement logic misses '
or something that delimits end of the string, and we should add that?
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.
cc @trueadm
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.
1) Added dependencies for create-react-class/prop-types to packages/react*/package.json 2) Renamed a warning let 3) Expanded on an inline comment example
scripts/rollup/modules.js
Outdated
case UMD_DEV: | ||
case UMD_PROD: | ||
const modulesAlias = {}; | ||
for (var legacyModule in legacyModules) { |
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.
nit: can we use const
or let
here?
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.
Yup!
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 checked over the Rollup still, it all looks good (the nit isn't important)
src/isomorphic/React.js
Outdated
Object.defineProperty(React, 'PropTypes', { | ||
get() { | ||
warning( | ||
didWarnPropTypesDeprecated, |
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.
Let's add something like "it will be removed completely in React 16"
Also, maybe we could make this warning and the one for React.createClass
more consistent.
src/isomorphic/React.js
Outdated
warning( | ||
warnedForPropTypes, | ||
'PropTypes have moved out of the react package. ' + | ||
'Use the prop-types package from npm instead.', |
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.
See #9399 (comment)
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.
Suggestion:
PropTypes have been moved to a separate package. Accessing React.PropTypes is no longer supported, and will be removed completely in React 16. Use the prop-types package on npm instead.
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.
And then with a link with more explanation
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.
Sweet. Will do.
scripts/rollup/modules.js
Outdated
case UMD_PROD: | ||
const modulesAlias = {}; | ||
for (var legacyModule in legacyModules) { | ||
modulesAlias[legacyModule] = resolve( |
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.
As per @gaearon's point above, if we put quotes around this, so it's moduleAlias[`'${legacyModule}'`]
then the legacyModule order shouldn't matter as the replace module literally "just" does string replacement :)
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.
Nice! I'll try that. 😁
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.
Changed in afdc9d2.
src/isomorphic/React.js
Outdated
@@ -106,8 +106,11 @@ if (__DEV__) { | |||
get() { | |||
warning( | |||
warnedForCheckPropTypes, | |||
'checkPropTypes has moved out of the react package. ' + | |||
'Use the prop-types package from npm instead.', | |||
'checkPropTypes have been moved to a separate package. ' + |
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.
Not "has been"?
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.
Words are hard 😅
'create-react-class is available on npm as a temporary, ' + | ||
'drop-in replacement.', | ||
'drop-in replacement. ' + |
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.
Should we make it clear it will keep on working indefinitely? "temporary" doesn't sound very reassuring.
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.
Yeah totally. I'll remove the word "temporary"
**what is the change?:** A couple of bugs and holes were introduced when cherry-picking facebook#9232 onto the 15.6 branch. This fixes them. We also needed to add some logic from facebook#9399 **why make this change?:** To keep tests passing and get this change working. **test plan:** `yarn test` **issue:** facebook#9398
**what is the change?:** A couple of bugs and holes were introduced when cherry-picking facebook#9232 onto the 15.6 branch. This fixes them. We also needed to add some logic from facebook#9399 **why make this change?:** To keep tests passing and get this change working. **test plan:** `yarn test` **issue:** facebook#9398
* react-create-class -> create-react-class * Fix issues/bugs introduced by merge conflict resolution **what is the change?:** A couple of bugs and holes were introduced when cherry-picking #9232 onto the 15.6 branch. This fixes them. We also needed to add some logic from #9399 **why make this change?:** To keep tests passing and get this change working. **test plan:** `yarn test` **issue:** #9398 * Move component base classes into a single file (#8918) * More fixes for issues introduced by rebasing **what is the change?:** - Remove some outdated 'require' statements that got orphaned in 'React.js' - Change 'warning' to 'lowPriorityWarning' for 'React.createClass' - Fix syntax issues in 'React-test' - Use 'creatReactClass' instead of ES6 class in ReactART - Update 'prop-type' dependency to use no higher than 15.7 because 15.8 limits the number of warnings, and this causes a test to fail. - Fix some mixed-up and misnamed variables in `React.js` - Rebase onto commit that updates deprecation messages - Update a test based on new deprecation messages **why make this change?:** These were bugs introduced by rebasing and tests caught the regressions. **test plan:** `yarn test` **issue:** #9398 * Reset `yarn.lock` **what is the change?:** I didn't mean to commit changes to `yarn.lock` except for the `prop-types` and `create-react-class` updates. **why make this change?:** To minimize the changes we make to dependency versions. **test plan:** `rm -rf node_modules` `yarn install` `yarn run build` `yarn test` * Run `yarn prettier`
* react-create-class -> create-react-class * Fix issues/bugs introduced by merge conflict resolution **what is the change?:** A couple of bugs and holes were introduced when cherry-picking facebook#9232 onto the 15.6 branch. This fixes them. We also needed to add some logic from facebook#9399 **why make this change?:** To keep tests passing and get this change working. **test plan:** `yarn test` **issue:** facebook#9398 * Move component base classes into a single file (facebook#8918) * More fixes for issues introduced by rebasing **what is the change?:** - Remove some outdated 'require' statements that got orphaned in 'React.js' - Change 'warning' to 'lowPriorityWarning' for 'React.createClass' - Fix syntax issues in 'React-test' - Use 'creatReactClass' instead of ES6 class in ReactART - Update 'prop-type' dependency to use no higher than 15.7 because 15.8 limits the number of warnings, and this causes a test to fail. - Fix some mixed-up and misnamed variables in `React.js` - Rebase onto commit that updates deprecation messages - Update a test based on new deprecation messages **why make this change?:** These were bugs introduced by rebasing and tests caught the regressions. **test plan:** `yarn test` **issue:** facebook#9398 * Reset `yarn.lock` **what is the change?:** I didn't mean to commit changes to `yarn.lock` except for the `prop-types` and `create-react-class` updates. **why make this change?:** To minimize the changes we make to dependency versions. **test plan:** `rm -rf node_modules` `yarn install` `yarn run build` `yarn test` * Run `yarn prettier`
This PR is prep work for a new 16 alpha release that (temporarily) re-adds getters with deprecation warnings for
React.PropTypes
,React.checkPropTypes
, andReact.createClass
. I'm hoping to get this new alpha cherry picked into RN 44.I've broken this PR into multiple commits to make it easier to review:
React.PropTypes
withprop-types
to avoid triggering our own warning message.React.createClass
that appeared after rebasing this branch. (reviewed by @flarnie)createClass
andPropTypes
to the mainReact
isomorphic object, behind one-time warning messages. (reviewed by @spicyj)tests-passing.txt
to remove tests that were deleted in this branch.package.json
dependencies to packages/react and packages/react-dom. Renamed a var. Expanded on an inline comment.)React.checkPropTypes
accessor too and updated build script.$FlowFixMe
.