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

Support for defaultProps will be removed from function components in a future major release. #1488

Closed
kurisu994 opened this issue Sep 21, 2023 · 7 comments · Fixed by #2230 or #2254
Closed
Assignees

Comments

@kurisu994
Copy link
Contributor

NutUI React 包名

@nutui/nutui-react

NutUI React 版本号

2.0.18

平台

h5

重现链接

https://github.com/kurisu994/next-nutui-demo

重现步骤

启动后访问 localhost:3000/login页面就会提示。
Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

期望的结果是什么?

没有这个警告

实际的结果是什么?

几乎所有nutui的组件都会有这个警告
image

环境信息

System:
OS: macOS 13.5.2
CPU: (10) arm64 Apple M1 Max
Memory: 667.27 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.0 - /opt/homebrew/opt/node@18/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.1 - /opt/homebrew/opt/node@18/bin/npm
Watchman: 2023.09.18.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 116.0.5845.187
Safari: 16.6
npmPackages:
@nutui/nutui-react: ^2.0.18 => 2.0.18

其他补充信息

No response

@kurisu994
Copy link
Contributor Author

最后只能过滤掉这个报错

const error = console.error;
  console.error = (...args: any) => {
    if (/defaultProps/.test(args[0])) return;
    error(...args);
  };

@kkfive
Copy link

kkfive commented Apr 9, 2024

同样的问题

@eiinu eiinu self-assigned this May 10, 2024
@eiinu eiinu linked a pull request May 15, 2024 that will close this issue
20 tasks
@xian107
Copy link

xian107 commented May 15, 2024

请问如何解决掉这个报错警告?很烦人!

@eiinu eiinu linked a pull request May 15, 2024 that will close this issue
20 tasks
@eiinu
Copy link
Member

eiinu commented May 15, 2024

请问如何解决掉这个报错警告?很烦人!

React 版本 <= 18.2.0 时,不会有这个警告。

@eiinu eiinu reopened this May 16, 2024
@Ttou
Copy link

Ttou commented Jun 15, 2024

降成 18.2.0 确实没这个提示了

@Duuun
Copy link

Duuun commented Jul 10, 2024

18.0.0还有

@imwangpan
Copy link

官方啥时候能修复这个问题呀?最新版 2.6.14 依然会报错:
Warning: o: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
at o (webpack-internal:///./node_modules/@nutui/icons-react/dist/es/icons/Marshalling.js:11:171)

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

Successfully merging a pull request may close this issue.

8 participants