首页 > 解决方案 > 样式化的组件自定义道具在 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>)

标签: reactjseslintstyled-componentseslintrctypescript-eslint

解决方案


推荐阅读