-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
False positive getDefaultProps warning when mixing development and production versions #9999
Comments
@mondwan can you share an example reproducing the issue? I'm not seeing the warning when using the latest |
https://jsfiddle.net/84v837e9/105/ For non minified version, it works as expected. However, it does not if using minified version Maybe related to issue #9689? |
@mondwan the issue is that you're using the minified Make sure you use the correct build for your environment (minified for production, unminified for development). |
Umm, but why this is a warning at the first place?
2017年6月20日 18:03,"Brandon Dail" <[email protected]>寫道:
… Closed #9999 <#9999>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9999 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADuAo2St_74neexrI9m8B4o0p6WQ3uXhks5sF5jkgaJpZM4N9x7V>
.
|
Because You'll never get the warning when using the correct build of |
That's the point. I am still using react.createClass instead of es6 class
even though this has been replaced by create-react-class. It should not get
a warning at the first place.
Or, create-react-class is made of es6 class. So, rules like that are
effective?
2017年6月20日 18:32,"Brandon Dail" <[email protected]>寫道:
… Because getDefaultProps is only used for components created with
createReactClass. For example, the warning will catch cases where someone
is moving from createClass to ES6 classes and they forget to remove
getDefaultProps in favor of defaultProps.
You'll never get the warning when using the correct build of
create-react-class. It's also important to use minified bundles for react
and react-dom in production, as they're much more performant. On the same
token, it's useful to use the unminified build in development as it
contains a sizeable set of useful checks and warnings.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9999 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADuAow64dLOLEjrIDwGn5DOSqeebBpttks5sF5-lgaJpZM4N9x7V>
.
|
You're getting the warning because you're using the production |
In general we don't support mixing production and development versions of libraries. |
It would still be nice if there was a way to avoid the false positive as this is pretty confusing. Maybe we can turn a flag into a number, and always set it in DEV. If it's not set then we're in PROD mode and shouldn't check. |
Ahhh. I see your points. Thanks for the explanations.
Actually, it always show warnings about this problem. However, it is hided
by development codes and those codes get striped when running in production.
In order to get rid of the warnings, I better changes those calls to
defaultProps. Am I correct?
2017年6月21日 下午3:52,"Brandon Dail" <[email protected]>寫道:
… You're getting the warning because you're using the production
create-react-class build with the development react build. The production
build strips out the code that prevents this warning in development
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9999 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADuAo5JvSA_WtxTh_YlhpNCQOTZqDLOlks5sGMvXgaJpZM4N9x7V>
.
|
No, to fix the false positive warnings, you need to either use:
The mistaken warning occur when you mix development and production versions of these two libraries. |
But it shows no warnings after changing to defaultProps as it suggested.
2017年6月21日 下午6:21,"Dan Abramov" <[email protected]>寫道:
… No, to fix the false positive warnings, you need to either use:
- react.js and create-react-class.js (development)
- react.min.js and create-react-class.min.js (production)
The mistaken warning occur when you mix development and production
versions of these two libraries.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9999 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADuAo0l2pw-Cielxxz32lpFlMcvgjIfUks5sGO62gaJpZM4N9x7V>
.
|
Both of them work. But even without changing it, it will still work correctly with createClass. The only issue is mistaken warning. And that mistaken warning happens because you mix development and production versions. |
@gaearon If I do understand it correctly that this can also affect the case when |
It is not super clear to me what you mean. Uglify doesn't mangle property names because it is generally unsafe. |
The action item here is to:
|
I'll try looking into this one. I'll update if I'm unable to make any progress. Thanks! |
I've opened a PR for this. Here's the test I used that reproduces the error.
|
Sure, feel free to look at it. Note #12064 is the most obvious fix but it doesn't actually solve the problem: we want to not do any extra steps in production. |
@benschac Are you still poking at this? Would like to take a crack at it if it's not being worked on. |
Nah, it's all you. Went into the rabbit hole of chatbots :D
…On Sun, Sep 16, 2018 at 3:25 PM, Charlie Truong ***@***.***> wrote:
@benschac <https://github.com/benschac> Are you still poking at this?
Would like to take a crack at it if it's not being worked on.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9999 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACYxIyHoAHEwkH-qRLXtJw9hTYI-ZAuxks5ubqWYgaJpZM4N9x7V>
.
|
I would like to take this as my good first issue |
I have a PR open (referenced above your comment) that attempts to address this issue. Awaiting feedback from @gaearon or someone else. Everyone on the core team likely very busy. |
Yeah I'm sorry I wasn't sure. I should've asked you first. I'm new to contributing so I am still trying to figure out how the flow of things work here. @CharlieTruong |
@ryansaam no worries. I'm new to contributing as well so still trying to figure it out. Feel free to look at my PR and provide feedback. May I approached it wrong. |
Hi I made a PR for this issue. The way I did it is adding a flag for dev mode and skip the check if it is not in dev mode. I need help for writing the test, especially how to test the mix development/release bundle in the test. Much appreciate if anyone can help. I also has some questions:
Sorry I am a new comer for react codebase and OSS contribution. ps: @CharlieTruong , hi my PR is highly inspired from yours. Only thing I changed is to use an explicit flag instead of implicitly rely on the existent of the |
@garyxuehong The React contributions docs mention that PRs should always be made against |
@jamesyesware The file I fixed against is in 15-stable branch only ( |
@jamesyesware and @s-kennedy, it was already explained #12064 (comment) by @gaearon . |
Hi! Is this work still needed? |
When function I think the problem is not in mixing development and production versions, but in relying on The table below describes different states and where bug occurs.
I have three possible ways in mind of how to fix that bug:
The question is how we suppose to fix this if there is no |
is anyone Working on this issue Can i? |
is this issue resolved? |
Hey @mondwan is this still relevant? |
To be honest, i am not sure. Hopefully, it was fixed a long time ago.
…On Thu, 15 Jun 2023, 18:51 Ashish Padhy, ***@***.***> wrote:
Hey @mondwan <https://github.com/mondwan> is this still relevant?
—
Reply to this email directly, view it on GitHub
<#9999 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5YBI2SOEVVG4JGQRL6LZDXLNDS5ANCNFSM4DPXD3KQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I want to work on this issue, please give me a chance |
@techwizard31 grow up bud! |
If the issue is not relevant, let's close it then :) |
As migrating from 15.4 to 15.5, I am rewrite original react components with
create-react-class
.However, there is a warning.
As I am really transferring from a classic
React.createClass
definition, I would like to ask is this warning appropriate? Or, this is a depreciation sames as the level of migrating tocreate-react-class
?Ooops, I get ticket #9999 :D
The text was updated successfully, but these errors were encountered: