【发布时间】:2021-05-26 18:49:47
【问题描述】:
我希望当我按下某个项目时将其值增加 x 时间。
我有一个名为“watchtime”的值,它是数字,当我单击将我带到项目屏幕的项目时,这是代码。
<View style={{ backgroundColor: "#f7f7f7" }}>
{this.state.RecipeArr.map((item, i) => {
return (
<View>
<TouchableOpacity
onPress={() => {
this.props.navigation.navigate("RecipeDetailScreen", {
Recipekey: item.key,
});
}}
style={styles.itemContainer}
></TouchableOpacity>
</View>
);
})}
</View>
这是组件安装在项目屏幕上的时间
componentDidMount() {
const dbRef = firebase
.firestore()
.collection("recipes")
.doc(this.props.route.params.Recipekey);
dbRef.get().then((res) => {
if (res.exists) {
const Recipe = res.data();
this.setState({
key: res.id,
name: Recipe.name,
category: Recipe.category,
intro: Recipe.intro,
watchtime: Recipe.watchtime,
image: Recipe.image,
ingredients: Recipe.ingredients,
preparation: Recipe.preparation,
isLoading: false,
});
} else {
console.log("Document does not exist!");
}
});
}
我的问题是当我点击某个项目时如何增加“观看时间”值。
【问题讨论】:
-
@Frank van Puffelen 我一定错过了,谢谢!
标签: reactjs firebase react-native google-cloud-firestore