【发布时间】:2020-07-11 01:11:03
【问题描述】:
所以我有一个使用 Native Base 作为 UI 库和 Typescript 的 React Native 应用程序。
现在有一个Accordion - 一旦它展开 - 就会呈现第二个(嵌套的)Accordion。问题是 TypeScript 抱怨:
A VirtualizedList contains a cell which itself contains more than one VirtualizedList of the same orientation as the parent list. You must pass a unique listKey prop to each sibling list.
这很好。但是当我将这个listKey 添加到我的Accordion 时,TypeScript 抱怨No overload matches this call.
如何抑制此警告?因为 Native Base 不提供 listKey 作为他们的 Accordion 的道具。
代码如下:
imports ...
type Props = {};
const Test: React.FC<Props> = ({}) => {
const renderNestedAccordion = () => {
return (
<View>
<ComponentWithAccordion></ComponentWithAccordion>
</View>
);
};
const dataArray = [{content: renderNestedAccordion()}];
return (
<Accordion
listKey={'acc'} // error
dataArray={dataArray}
/>
);
};
export default Test;
【问题讨论】:
标签: reactjs typescript react-native native-base