【发布时间】:2017-11-16 18:00:15
【问题描述】:
问题是这样的。基于状态变量,我要么在 ListView 渲染行上渲染可重用组件,要么返回 null。
//renderRow
if (this.state.openSections[sectionID] === false) {return null}
return (<View style = {{flex :1, overflow : 'hidden'}}>
<CalculatorItem item = {rowData}></CalculatorItem>
</View>)
当按下某个部分时,openSections 对象中的相应条目会切换为 true 或 false,指示应呈现行,以便对用户可见。
sectionPressed: function(sectionID) {
...
//create a new openSections var and set the state
this.setState((state, props) => { return { openSections }});
}
但是,listview 项目不会被渲染。
有什么线索吗?
【问题讨论】:
-
需要更多上下文。列表视图在哪里?
-
你能在这里分享代码吗?
标签: javascript listview react-native