gpt4 book ai didi

javascript - React JS - ESLint - 忽略具有 UNSAFE_componentWillMount、UNSAFE_componentWillUpdate 和 UNSAFE_componentWillReceiveProps 的组件的规则

转载 作者:行者123 更新时间:2023-12-04 01:49:38 25 4
gpt4 key购买 nike

目前,我遇到了这些 linting 错误:

ESLint:UNSAFE_componentWillUpdate 应该放在 someFunction (react/sort-comp) 之后

ESLint:标识符“UNSAFE_componentWillUpdate”不是驼峰式。 (驼峰式)

目前,我无法找到正确的规则添加到 .eslintrc 以应用于前置的 UNSAFE_ 组件生命周期。我试图让它适用于 react/sort-compcamelcase 规则,任何线索/帮助将不胜感激

最佳答案

你可以将它添加到你的 eslint

"camelcase": [
"error", {
"ignoreDestructuring": true,
"allow": [ "^UNSAFE_" ]
}
],

这基本上只允许所有重命名的 UNSAFE_ 生命周期方法。

关于javascript - React JS - ESLint - 忽略具有 UNSAFE_componentWillMount、UNSAFE_componentWillUpdate 和 UNSAFE_componentWillReceiveProps 的组件的规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53844282/

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