Skip to content
New issue

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

🐛[BUG] actions.render方法无法响应式执行 #200

Closed
HongwuQz opened this issue May 10, 2024 · 0 comments · Fixed by #209
Closed

🐛[BUG] actions.render方法无法响应式执行 #200

HongwuQz opened this issue May 10, 2024 · 0 comments · Fixed by #209
Labels
bug Something isn't working

Comments

@HongwuQz
Copy link

🐛 bug 描述

actions.render方法中无法获取异步数据来根据动态数据自定义actionsBar

📷 复现步骤

只要actions.render方法中使用了异步获取的数据,就会一直得不到更新

🏞 期望结果

actions.render中可以依赖函数中使用到的state重新被调用

💻 复现代码

export const Chat = () => {
  const [actionsContents, setActionsContents] = useState<string[]>([]);

  useEffect(() => {
    fetch('/xxx').then((res: string[]) => {
      setActionsConfig(res)
    })
  }, [])
  
  return (
    <ProChat
      actions={{
        render: () => {
          // 这里的actionsContents会一直是默认值
          return actionsContents.map(actions => (
            <button>actions</button>
          ))
        }
      }}
    />
  )
}

© 版本信息

  • @ant-design/pro-chat 版本: [e.g. 1.13.4]
  • 浏览器环境 Chrome
  • 开发环境 [mac OS]
@ONLY-yours ONLY-yours added the bug Something isn't working label May 14, 2024
@ONLY-yours ONLY-yours linked a pull request May 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants