reactjs - 样式化的组件自定义道具在 typescript eslint 中返回 no-undef
问题描述
我正在将自定义道具传递给我在 React 中的样式化组件。运行代码时,typescript eslint 会输出警告:
'isActive' is not defined no-undef
但代码似乎工作正常,打字稿没有报告任何错误。
请在下面查看我的代码:
JSX
import React from 'react';
import styled from 'styled-components';
const Title= styled.div<{ isActive: boolean }>`
${({ isActive}) => isActive && 'color: blue;'}`;
interface IFunctionName{ active:boolean }
const FunctionName: React.FC<IFunctionName> = ({ active }) =>
(<div><Title isActive={active}> test </Title></div>)
解决方案
推荐阅读
- asp.net-core - 带有查询字符串的 RazorPage 的友好 URL
- c - 在C中使用for循环的系列之和
- sql - Entity Framework Core OwnsOne 在同一张表上不必要的 JOINS
- google-cloud-robotics - cert-manager 无法生成云机器人证书
- javascript - 使用内联 javascript 设置一些值
- c++ - 如何在directx/c++中进行平移/缩放操作
- javascript - Firebase 自定义操作网址中断验证
- android-studio - recyclerView.isLayoutFrozen 已弃用。Kotlin 中的替代方案是什么?
- mysql - 如何创建具有两个连接到同一个查找表的查询
- django - TypeError: 无法获取,我得到的错误,我使用 reactjs 作为前端和 django 作为后端