Skip to content

Instantly share code, notes, and snippets.

View miglcesp01's full-sized avatar

Miguel Licea miglcesp01

View GitHub Profile
@JohnGoodman
JohnGoodman / tawk-to-widget-toggle-in-react.js
Last active September 8, 2023 06:52
Tawk.to React function to to toggle showing and hiding the widget
// In a react app, the Tawk.to widget loads before the React app, causing an error to be thrown
// if you need to interact with the widget on first load
// The code below checks to make see if the widget it initialized
// It handles toggling the widget even when it has not initalized yet
function tawkWidgetToggle(show){
// Ensure the Tawk object has initalized
if(window.$_Tawk && window.$_Tawk.init){