0
Answered

Is there an example to call sayText() js function from react component?

Eric Xiao 1 month ago in SitePal Gold updated 4 weeks ago 9

Answer

Answer
Under review

Hi Eric - 


Yes there is, on the SitePal support page:

www.sitepal.com/support

Here is a direct link to the example:

https://sitepal.com/api/examples/react/index.html


And a direct link to the accompanying documentation, please review:

https://sitepal.com/docs/Embed_SitePal_in_JS_Frameworks.pdf


Hope this helps, lmk if any questions.

Regards,

Gil

Answer
Under review

Hi Eric - 


Yes there is, on the SitePal support page:

www.sitepal.com/support

Here is a direct link to the example:

https://sitepal.com/api/examples/react/index.html


And a direct link to the accompanying documentation, please review:

https://sitepal.com/docs/Embed_SitePal_in_JS_Frameworks.pdf


Hope this helps, lmk if any questions.

Regards,

Gil

Hi, this exemple shows how to add the avatar in react, but how do we use functions like sayText() after ?

i'm getting this :

'sayText' is not defined

ok it's working using window.sayText !

Great - I'm glad to hear it. 

I've sent a note to engineering - but you found the solution first...

Take care,

Gil

Hi Cyril, can you share your code segment here?  Thanks!

I am getting "react-dom.development.js:23275 Uncaught TypeError: window.sayText is not a function"

<td align="center">
{/* Embedding SitePal avatar */}
<div id="embed" className="Comment"></div>
<button name="sayButton" onClick={window.sayText("How are you doing today!", 3, 1, 3)}>Click Here</button>
</td>

window.sayText works only once the sitepal avatar has loaded.

i'm using another function on the onClick. and it that function i have written:

if (window.sayText) window.sayText(message,3,4,3);


hope it helps


Thank you very much, Cyril !  It works with the if check.