最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Can't update a state variable after onStartingAcw event - Stack Overflow

programmeradmin2浏览0评论

I'm trying to update a state variable (message) after onStartingAcw event listener, but this not works (I don't have error menssages of the intent of update), I have a console.log on the handlerCallDestroyed and this works fine when the agent enters on ACW (after the call ends), but I can't update the value of message. This is a 3p App working on Amazon Connect Agent Workspace, I'm running my App on localhost:3000 (attached to Amazon Connect Agent Workspace) Am I doing somethis wrong? This is my code:

import { useState, useEffect } from "react";
import { AmazonConnectApp } from "@amazon-connect/app";
import { ContactClient, AgentClient, ContactStartingAcwEventData } from "@amazon-connect/contact"; 
import './App.css';

const provider = AmazonConnectApp.init({
  onCreate: (event) => {
    const { appInstanceId, appConfig } = event.context;
    console.log('App initialized:', appInstanceId);
    console.log("Permissions:", appConfig.permissions);
  },
  onDestroy: (event) => {
    console.log('App being destroyed', event);
  }
});

function App() {
  const [message, setMessage] = useState("Esperando eventos...");

  useEffect(() => {
    const agentClient = new AgentClient();
    const contactClient = new ContactClient();

    const handlerCallDestroyed = (ContactStartingAcwEventData) => {
      console.log("test", ContactStartingAcwEventData);
      setMessage("Llamada finalizada - ACW completado");
    };

    contactClient.onStartingAcw(handlerCallDestroyed);

  }, []);

  return (
    <div className="App">
      <p className="message">Mensaje: {message}</p>
    </div>
  );
}

export default App;
发布评论

评论列表(0)

  1. 暂无评论