React无未使用的proptypes错误;无法理解导致错误的结构问题



我是React的新手,很难理解我收到的错误。我设法修复了其他一些此类错误,但这一特定错误让我迷失了方向。在一个打字脚本文件中,我有:

export interface FarmsProps {
tokenMode?: boolean
}

然后进一步降低

const Farms: React.FC<FarmsProps> = (farmsProps) => {
const { path } = useRouteMatch()
const TranslateString = useI18n()
const farms = useFarms();
const prices = usePrices()
const farmsLP = useFarms()
const cakePrice = usePriceCakeBusd()
const bnbPrice = usePriceBnbBusd()
const { account, ethereum }: { account: string; ethereum: provider } = useWallet()
const { tokenMode } = farmsProps;
const [modalOpen, setModalOpen] = useState(true)
const handleModal = async () => {
setModalOpen(!modalOpen)
}

我在编译时得到以下错误:

Failed to compile.
src/views/LiqPools/Farms.tsx
Line 26:6:  'tokenMode' PropType is defined but prop is never used  react/no-unused-prop-types
Search for the keywords to learn more about each error.

非常感谢任何指导。

在我的例子中,我刚刚在rules对象的.eslintrc文件中添加了一行。

"rules": {"react/no-unused-prop-types": 0}

最新更新