【问题标题】:Warning weird: is declared but its value is never read奇怪的警告:已声明但它的值从未被读取
【发布时间】:2021-02-25 06:53:14
【问题描述】:

这是我的代码:'Skeleton' 已声明,但它的值从未被读取。

import React from 'react';
import {
    FlatList, View, StyleSheet
} from 'react-native';
// But warning here 
import { Skeleton, Colors } from '@momo-platform/component-kits';

const SkeletonLoadingChat = () => {
    const data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    return (
        <FlatList
            style={{ padding: 15 }}
            data={data}
            ListHeaderComponent={() => {
                return (
                    <View style={styles.headerSkelation}>
                        <View style={styles.avataSkelation} />
                        <View style={styles.lineSkelation} />
                    </View>
                );
            }}
            renderItem={({ item, index }) => {
                return (
                    // I used Skeleton here
                    <Skeleton.Custom
                        left={<Skeleton.Media size={52} />}
                        style={styles.skeletionItem}
                    >
                        <Skeleton.Line style={styles.width_1_9} />
                        <Skeleton.Line style={styles.width_80} />
                    </Skeleton.Custom>
                );
            }}
        />
    );
}

我使用了 Skeleton,但它仍然显示警告 界面骨架

export interface Skeleton extends SkeletonProps {
  Line?: React.ReactElement,
  Media?: React.ReactElement,
  Custom?: React.ReactElement,
}

如果我删除导入骨架,它会显示错误

【问题讨论】:

  • Skeleton在使用Skeleton.Custom时怎么会是一个接口?
  • 如果您删除导入,您会收到错误消息吗?如果有,是哪一个?
  • 是的,如果我删除导入应用程序显示错误
  • @Bergi in Skeleton 我看到属性自定义
  • 我的猜测是@momo-platform/component-kits 类型声明是错误的,使用interface 应该是namespace。不幸的是,我无法在网上找到他们的源代码来确认。

标签: javascript reactjs typescript react-native visual-studio-code


【解决方案1】:

您可以放心地忽略此警告。

【讨论】:

  • 我通常会重构代码,所以如果我不小心我可以删除 Skeleton :(
猜你喜欢
  • 1970-01-01
  • 2019-06-23
  • 2023-03-15
  • 1970-01-01
  • 2022-08-10
  • 2018-09-28
  • 1970-01-01
  • 2021-12-23
  • 1970-01-01
相关资源
最近更新 更多