【发布时间】:2019-09-05 21:59:14
【问题描述】:
我想在我的 react 本机应用程序中添加一个评论部分,类似于 instagram 的应用程序。我正在使用 getstream 活动提要并尝试从 react-native-activity-feed 导入 CommentField,但是在使用它时出现不变的违规错误。但是,我并不完全相信 CommentField 会给我我想要的评论部分类型。 getstream 是否支持这一点,还是我需要创建自己的评论字段并将其保存在数据库中?
编辑:
我有这个活动:
const CustomActivity = (props) => {
return (
<Activity
{...props}
Footer={
<>
<CommentList
CommentItem={({ comment }) => ( <CommentItem comment={comment} /> )}
activityId={props.activity.id}
reactions={props.activity.latest_reactions}
/>
<Image source={ require('./images/logo.png') } style={{width:98, height:22}}/>
<LikeButton {...props} />
<CommentBox
onSubmit={(text) =>
props.onAddReaction('comment', CustomActivity, { text: text })
}
styles={{ container: { height: 78 } }}
/>
</>
}
/>
);
};
然后渲染:
<FlatFeed
feedGroup = "timeline"
userID = User ID is put here
Activity={CustomActivity}
notify/>
我目前在提交评论时收到此错误:Errors for fields 'activity_id', 'parent'
我认为这可能与 CommentList 中的 activityId 有关,但我不太确定
【问题讨论】:
-
您能否添加用于此的代码以及有关您想要做什么的更多信息?
-
@TommasoBarbugli 我已经用我现在得到的代码和错误更新了我的问题
-
我认为CustomActivity的错误在于:props.onAddReaction('comment', CustomActivity, { text: text }),这应该是activity对象,而不是你的自定义组件。