可能重复,但找不到任何明确的答案。
Dependabot 无法将 nth-check 更新到无漏洞版本 由于以下>冲突的依赖项,可以安装的最新可能版本是 1.0.2:
react-scripts@5.0.0 通过对 css-select@2.1.0 的传递依赖需要 nth-check@^1.0.2
刚刚从 4.0.0 升级到react-scripts@5.0.0。
在我的代码中,我没有任何显式使用componentWillMount,但在运行webpack.
react-dom.development.js:12386 警告:componentWillMount 已重命名,不推荐使用。有关详细信息,请参阅 https:/fb.me/react-unsafe-component-lifecycles。
- 将有副作用的代码移动到 componentDidMount,并在构造函数中设置初始状态。
- 将 componentWillMount 重命名为 UNSAFE_componentWillMount 以在非严格模式下抑制此警告。在 React 17.x 中,只有 UNSAFE_ 名称有效。要将所有已弃用的生命周期重命名为其新名称,您可以
npx react-codemod rename-unsafe-lifecycles在项目源文件夹中运行。请更新以下组件:foo、bar
我确实运行了建议的npx react-codemod rename-unsafe-lifecycles,但警告并没有消失,只是将其措辞更改为
react-dom.development.js:12386 警告:componentWillMount 已重命名,不推荐使用。[...]
在这里,foo和bar都是我们团队编写的自定义组件,以及外部库的一些组件。对 Visual Studio 解决方案的完整搜索componentWillMount没有给我任何结果。有人可以解释一下我做错了什么吗?
我在另一个问题上读到一条评论,说明
我没有任何明确的地方 with
componentWillMount,但在构造函数之后我确实有 [...] 一行代码,其中state={ tabindex:0 }如何将其“移动”到构造函数中?
答案是写
constructor(props) {super(props); this.state = { tabindex:0 }}。有人可以解释一下这里发生了什么吗?我必须在我们的代码中寻找什么样的模式?
printWarning @ react-dom.development.js:12386
lowPriorityWarningWithoutStack @ react-dom.development.js:12407
./node_modules/react-dom/cjs/react-dom.development.js.ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings @ react-dom.development.js:12577
flushRenderPhaseStrictModeWarningsInDEV @ react-dom.development.js:25641 …Run Code Online (Sandbox Code Playgroud)