gpt4 book ai didi

reactjs - componentWillReceiveProps 已重命名

转载 作者:行者123 更新时间:2023-12-03 13:20:13 27 4
gpt4 key购买 nike

我正在使用使用 ReactSwipableView 包的 Material ui SwipeableViews,我在控制台上收到此错误

react-dom.development.js:12466 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at:
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: ReactSwipableView

有什么方法可以消除这个错误,我尝试过 UNSAFE_componentWillReceiveProps 但没有任何改变

最佳答案

It seems this has been reported to the maintainers already.

现在,作为开源软件的消费者,您可以:

最终,这不是与您的软件相关的错误,而是与它所依赖的依赖项相关的错误。修复这些问题实际上并不是您的责任。如果您的应用程序运行,那就没问题了。来自 react-dom.development.js 的警告不会出现在生产环境中。

* 编辑:this commit 起( PR ),react-swipable-views 不再使用 componentWillReceiveProps。如果您仍然遇到此错误,请确保您使用的是 v0.14.0 或更高版本。

关于reactjs - componentWillReceiveProps 已重命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58924617/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com