我在我的应用程序中使用 react-native-collapsible 来实现手风琴视图。
https://github.com/oblador/react-native-collapsible
它工作得很好,但是我们在不希望 Accordion 点击功能的地方改变了要求,即 Accordion 不应该在点击时展开。我可以通过创建一个单独的 div 来做到这一点,但我正在考虑重用相同的 react-native-collapsible 并实现相同的工作。
手风琴代码-
const SECTIONS = [
{
title: 'First',
content: 'Lorem ipsum...',
},
{
title: 'Second',
content: 'Lorem ipsum...',
},
];
class AccordionView extends Component {
state = {
activeSections: [],
};
_renderContent = section => {
return (
<View style={styles.content}>
<Text>{section.content}</Text>
</View>
);
};
}
render() {
return (
<Accordion
sections={SECTIONS}
activeSections={this.state.activeSections}
renderSectionTitle={this._renderSectionTitle}
renderHeader={this._renderHeader}
renderContent={this._renderContent}
onChange={this._updateSections}
/>
);
}
}
所以,为了实现这一点,我试图从我的 Accordion 中完全删除 renderContent 函数,但这给了我错误 -
TypeError: renderContent is not a function
有人可以告诉我是否有办法在重用相同代码库的同时隐藏手风琴内容。任何帮助深表感谢。