Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
trying to implement a talks.js library to create chat on react

I'm trying to implement a talks.js library to create chat on react I follow all steps that show up here https://talkjs.com/docs/Getting_Started/Frameworks/React/ but it's not working, I don't know what I'm missing up

I'm exporting this component below and importing in home component

import { useRef } from 'react';
import Talk from 'talkjs';

const UserChat = () => {

const talkjsContainer = useRef('root');
// const currentUser = this.props.currentUser;
    useEffect(() => {
      Talk.ready.then(( ) => {

        var me = new Talk.User({
            id: '123456',
            name: 'Alberto',
            email: 'alice@example.com',
            photoUrl: 'https://demo.talkjs.com/img/alice.jpg',
            welcomeMessage: 'Hey there! How are you? :-)',
        });

        window.talkSession = new Talk.Session({
            appId: 'tUOOCMxO',
            me: me,
          });


          var other = new Talk.User({
            id: '654321',
            name: 'Sebastian',
            email: 'Sebastian@example.com',
            photoUrl: 'https://demo.talkjs.com/img/sebastian.jpg',
            welcomeMessage: 'Hey, how can I help?',
            role: 'default',
          });
        
          var conversation = window.talkSession.getOrCreateConversation(
            Talk.oneOnOneId(me, other)
          );
        
          conversation.setParticipant(me);
          conversation.setParticipant(other);

          var inbox = window.talkSession.createInbox();
          inbox.select(conversation);

       
          inbox.mount(talkjsContainer.current)

      });
    }, []);

    
        return(
            
            <div ref={talkjsContainer}></div>
        ) 
        
    

}

export default UserChat;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you can use this

   const startChat = (user) => {
    if (!window.talkSession ) {
      return false;
    }
    const other = new Talk.User({
      id: "1222222",
      name: "james",
      email:"james1@yandex.com",
      role: buyer 
    });
    const conversation = 
    window.talkSession.getOrCreateConversation(Talk.oneOnOneId(me, other));
    conversation.setParticipant(me);
    conversation.setParticipant(other);

    const popup = window.talkSession.createPopup(conversation, { keepOpen: false });
    popup.mount({ show: false });

    popup.show();
  };
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda