I have the following App Component :-
import React, { useEffect } from "react";
import Home from "./pages/Home";
import About from "./pages/About";
function App() {
useEffect(() => {
var Tawk_API = Tawk_API || {},
Tawk_LoadStart = new Date();
(function () {
var s1 = document.createElement("script"),
s0 = document.getElementsByTagName("script")[0];
s1.async = true;
s1.src = "https://embed.tawk.to/5ab8d/default";
s1.charset = "UTF-8";
s1.setAttribute("crossorigin", "*");
s0.parentNode.insertBefore(s1, s0);
})();
Tawk_API.onLoad = function () {
console.log("chat loaded");
Tawk_API.setAttributes(
{
name: "Test Name",
email: "email@email.com",
hash: "hash value",
},
function (error) {}
);
};
}, []);
return (
<div>
<div className="container-fluid rtl">
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
</div>
</div>
);
}
export default App;
I can see that chat widget, but when i am starting a chat , don't get the visitor assigned name.
How can i use the setAttributes in reactjs?