【发布时间】:2021-05-13 11:40:03
【问题描述】:
我尝试使用时刻显示为我从 Firestore 发布的帖子选择的事件日期。现在它只打印当天,所以我显示日期但不是正确的方式。我没有收到错误消息。我试图将时间戳更改为“dateUpload”。但它在我的文本组件中打印了“无效日期”。有没有人知道我能做什么?
这就是我的平面列表的显示方式:
postDate={moment(item.timestamp).format("ll")}
在我的 redux Action.js 中
export function fetchFollowingUsersPosts(uid) {
return ((dispatch, getState) => {
firebase.firestore()
.collection("posts")
.doc(uid)
.collection("userPosts")
.orderBy("creation", "asc")
.get()
.then((snapshot) => {
const uid = snapshot.query.EP.path.segments[1];
const user = getState().usersState.users.find(el => el.uid === uid);
const posts = snapshot.docs.map((doc) => {
const { data: firebaseTimestamp, ...rest } = doc.data()
const id = doc.id;
const data = firebaseTimestamp ? moment(firebaseTimestamp.toDate()) : null
return {
...rest,
id,
user,
...data
}
})
//console.log(posts);
dispatch({ type: USERS_POSTS_STATE_CHANGE, posts, uid, })
})
})
}
我的数据库中的图像:
【问题讨论】:
标签: react-native date redux expo redux-firestore