PARAMS发送到声明的外部库,但从来没有使用过

PARAMS发送到声明的外部库,但从来没有使用过

问题描述:

我使用jsoendermann/rn-section-list-get-item-layout NPM包,以帮助我定义getItemLayout属性SectionList。我需要定义getItemLayout属性才能运行scrollToLocation()PARAMS发送到声明的外部库,但从来没有使用过

文档状态,它应该这样被使用:

import sectionListGetItemLayout from 'react-native-section-list-get-item-layout' 

// cut.. 

    this.getItemLayout = sectionListGetItemLayout({ 
     // The height of the row with rowData at the given sectionIndex and rowIndex 
     getItemHeight: (rowData, sectionIndex, rowIndex) => 
                sectionIndex === 0 ? 100 : 50, 
    } 

    render() { 
    return (
     <SectionList 
     {...otherStuff} 
     getItemLayout={this.getItemLayout} 
     /> 
    ) 
    } 
} 

打字稿(2.5.3)编译器抱怨这一行:

getItemHeight:(rowData,sectionIndex和rowIndex)= > sectionIndex === 0? 100:50,

error TS6133: 'rowData' is declared but never used. error TS6133: 'rowIndex' is declared but never used.

我想都rowDatarowIndex在故宫包在内部使用,但我怎么告诉给TS编译器?

说服编译器,rowDatasectionIndex在其他地方使用可能是徒劳的,因为错误是他们没有用在这个特定的功能。

https://www.triplet.fi/blog/typescript-getting-rid-of-error-x-is-declared-but-never-used/,解决方法是用{},它摆脱的参数名称的取代rowDatasectionIndex,从而消除未使用的参数。