我正在创建一个 androidTV 应用程序并尝试使用 TouchableNativeFeedback 获取当前以 FlatList 为重点的项目。
当 FlatList 项目具有焦点时,我尝试使用“onFocus”来更改状态,但是当应用程序呈现时,它似乎专注于每个项目,因为它被加载到 FlatList 中,导致许多 SetState 更新出错。我尝试在 onfocus 中使用“()=>”来停止它在渲染时运行,但这似乎完全停止了它的工作
<View style={styles.containerItemNow}>
<TouchableNativeFeedback background={TouchableNativeFeedback.Ripple('#f14621', true)} onFocus={this.UpdateStatus(item.status)} onPress={() => this.downloadfile(item.url)}>
<View style={styles.containerItemNowSelected}>
<Text style={{color: 'white'}}>{item.title}</Text>
</View>
</TouchableNativeFeedback>
</View>
Run Code Online (Sandbox Code Playgroud)
我希望当用户使用 d-pad 移动时,该项目会以涟漪效果突出显示并运行 onfocus 并更新所需的状态,但即使项目涟漪效应显示 onfocus 未运行,也不会发生这种情况
android-tv react-native react-native-android react-native-flatlist