We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
actionsRender,写了一个点赞、点踩,点击更新className高亮,没生效
在 actionsRender 里面打印feedbacks 没更新,但是外层feedbacks字段更新了
const [feedbacks, setFeedbacks] = useState<{}>({});
const submitFeedback = (type, id) => {
setFeedbacks({ ...feedbacks, id: type })
}
<ThumbsUp theme="outline" className={btn-icon ${feedbacks[id] === 'THUMB_UP' ? 'active' : ''}} onClick={() => submitFeedback('THUMB_UP', id)} />
btn-icon ${feedbacks[id] === 'THUMB_UP' ? 'active' : ''}
The text was updated successfully, but these errors were encountered:
动态点赞更新className高亮,没生效,但是历史记录进来,是生效的。
问题貌似是,actionsRender 不支持动态更新,源码里这段useMemo的依赖项actions,组件使用时,应该怎么处理actions,可以让它动态更新
const actionsDom = useMemo(() => { if (chatItemRenderConfig?.actionsRender === false) return null; if (error) return null; const dom = ( <Actions actions={actions} className={${cx(styles.actions, ${prefixClass}-list-item-actions)}} /> ); return chatItemRenderConfig?.actionsRender?.(props, dom) || dom; }, [actions]);
${cx(styles.actions,
)}
Sorry, something went wrong.
我是重写了ActionIconGroup, 实现了效果, 大概如下 const [cacheFeedback, setCacheFeedback] = useState(feedback || 0); const items: ActionIconGroupProps["items"] = [ { icon: () => { return ( <ThumbsUp size="12" color={cacheFeedback == 1 ? "#ff6600" : "rgba(0, 0, 0, 0.45)"} /> ); }, key: "thumbs-up", label: "赞", }]
const [cacheFeedback, setCacheFeedback] = useState(feedback || 0); const items: ActionIconGroupProps["items"] = [ { icon: () => { return ( <ThumbsUp size="12" color={cacheFeedback == 1 ? "#ff6600" : "rgba(0, 0, 0, 0.45)"} /> ); }, key: "thumbs-up", label: "赞", }]
感谢,用这个方法可以解决
No branches or pull requests
🐛 bug 描述
actionsRender,写了一个点赞、点踩,点击更新className高亮,没生效
📷 复现步骤
actionsRender,写了一个点赞、点踩,点击更新className高亮,没生效
🏞 期望结果
在 actionsRender 里面打印feedbacks 没更新,但是外层feedbacks字段更新了
💻 复现代码
const [feedbacks, setFeedbacks] = useState<{}>({});
const submitFeedback = (type, id) => {
}
<ThumbsUp
theme="outline"
className={
btn-icon ${feedbacks[id] === 'THUMB_UP' ? 'active' : ''}
}onClick={() => submitFeedback('THUMB_UP', id)}
/>
The text was updated successfully, but these errors were encountered: