react-native - 如何添加评论以在本机反应中获取流
问题描述
我想在我的 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 有关,但我不太确定
解决方案
您将需要使用CommentBox和CommentList组件。我们在示例应用程序中执行以下操作:
<SinglePost
activity={activity}
feedGroup={feedGroup}
userId={userId}
Activity={(props) => (
<React.Fragment>
<Activity
{...props}
/>
<CommentList
CommentItem={({ comment }) => ( <CommentItem comment={comment} /> )}
activityId={props.activity.id}
reactions={props.activity.latest_reactions} />
</React.Fragment>
)}
Footer={(props) => {
return (
<CommentBox
onSubmit={(text) =>
props.onAddReaction('comment', activity, { text: text })
}
avatarProps={{
source: (userData) =>
userData.data.profileImage,
}}
styles={{ container: { height: 78 } }}
/>
);
}}
/>
推荐阅读
- postgresql - Postgres 在现有表上添加列需要很长时间
- python - Python bcubed clustering metric-TypeError:&:'dict'和'dict'不支持的操作数类型
- sql - Postgresql 在相对中小型表上更新缓慢
- python-3.x - Python,tkinter:无法使用 Pickle 保存
- android-recyclerview - 将新数据添加到现有 Recyclerview 适配器数据的底部
- c# - .Net 中 Math.Floor() 和 Math.Truncate() 之间的区别
- spring-boot - 如何测试不产生事件的状态存储聚合
- python - 使用数组估计 Sympy 中 2 阶张量的双重收缩
- python - 如何同时运行节点和 django 服务器
- php - 无法在 centos 7 上安装 PHP 的 ZIP 归档管理扩展