Skip to content
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

求助: 打包报错 getDefaultProps is only used on classic React #130

Closed
zjxpcyc opened this issue Apr 13, 2018 · 10 comments
Closed

求助: 打包报错 getDefaultProps is only used on classic React #130

zjxpcyc opened this issue Apr 13, 2018 · 10 comments

Comments

@zjxpcyc
Copy link

zjxpcyc commented Apr 13, 2018

Error: Warning: getDefaultProps is only used on classic React.createClass definitions. Use a static pr  operty named `defaultProps` instead.

环境:
win10 x64
node v8.7.0
npm 5.4.2
框架使用 react-static
执行框架打包命令 yarn build 就报上面的错误。

如果我把使用 rc-menu 的地方注释掉,就能正常打包。

@zjxpcyc zjxpcyc changed the title 求助: 打包报错 求助: 打包报错 getDefaultProps is only used on classic React Apr 13, 2018
@chenshuai2144
Copy link
Contributor

你是不是使用了React.createClass?

@zjxpcyc
Copy link
Author

zjxpcyc commented Apr 13, 2018

没有,在我使用 rc-menu 的组件里面,我是 这样写的
export default class extends PureComponent

@zjxpcyc
Copy link
Author

zjxpcyc commented Apr 14, 2018

@picodoth 帮忙看看呢

@picodoth
Copy link
Contributor

@zjxpcyc 不好意思才看到
#133 应该能解决这个问题把

@zjxpcyc
Copy link
Author

zjxpcyc commented Apr 23, 2018

我这刚刚测试了下,还是不行。要不,你们那边用 react-static 随便 create 一个项目试试?

我这边,没有继续使用这个组件,我自己写了一个简单的。

如果需要,你们可以随时 close 这个 issue

@picodoth
Copy link
Contributor

picodoth commented Jun 9, 2018

奇怪,menu里面已经没有getDefaultProps了。。

@picodoth picodoth closed this as completed Jun 9, 2018
@picodoth
Copy link
Contributor

@zjxpcyc 有个同事也遇到了这个问题,不过 rc-menu 是旧版本 6..

@yesmeck
Copy link
Member

yesmeck commented Jun 15, 2018

@echizen
Copy link

echizen commented Jun 25, 2018

1ff8606c-fe3f-4758-a0a7-103fe42d2470

还有种情况,从某个版本开始create-react-class里加了以上判断,所以检查下是否你的develop环境的process.env.NODE_ENV变量没设置正确

@zlv-thisF
Copy link

遇到了这个问题,但是还是没有理解,确实如代码显示的情况,我在production环境,没有warnning;
但是在其他环境我没有使用getDefaultProps,看了下warning来自rc-tabs和rc-menu,我没有用cdn的antd.min.js或者antd.js. 现在test环境 stage环境都是waring。。。 实在不知道怎么解决 @echizen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants