react: False positive getDefaultProps warning when mixing development and production versions
As migrating from 15.4 to 15.5, I am rewrite original react components with create-react-class.
However, there is a warning.
react-15.5.4.js?bust=1497843639843:3287 Warning: getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.
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 to create-react-class?
Ooops, I get ticket #9999 😄
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 24
- Comments: 39 (4 by maintainers)
Hi! Is this work still needed? I’m looking to grab a first issue to contribute to, but after spending some time on this thread it seems to have been just left out.
is anyone Working on this issue Can i?
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:
Because
getDefaultPropsis only used for components created withcreateReactClass. For example, the warning will catch cases where someone is moving fromcreateClassto ES6 classes and they forget to removegetDefaultPropsin favor ofdefaultProps.You’ll never get the warning when using the correct build of
create-react-class. It’s also important to use minified bundles forreactandreact-domin 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.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.
is this issue resolved?
@mondwan the issue is that you’re using the minified
create-react-classbuild, but the unminifiedreactbuild. This means that the internal flag thatcreate-react-classuses to suppress this warning is not applied, so React warns.Make sure you use the correct build for your environment (minified for production, unminified for development).
@techwizard31 grow up bud!
Nah, it’s all you. Went into the rabbit hole of chatbots 😄
On Sun, Sep 16, 2018 at 3:25 PM, Charlie Truong notifications@github.com wrote:
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.
You’re getting the warning because you’re using the production
create-react-classbuild with the developmentreactbuild. The production build strips out the code that prevents this warning in development