Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.07 KB

how-to-use.md

File metadata and controls

51 lines (40 loc) · 1.07 KB

How to Use

Here are the basic how to usse callback and access the expose functions from the plugin. You can see the list of APIs in the API reference


Expose Function

To access the expose functions, you will need to declare a variable and pass it as ref props, this will return an object that contains API functions from the plugin after the widget is load.

function App() {
    let $tawkMessenger;

    onMount(() => {
        $tawkMessenger.maximize();
    });

    return (
        <TawkMessenger
            propertyId="property_id"
            widgetId="widget_id"
            ref={$tawkMessenger}/>
    );
}

Using Callbacks

Using the API callbacks, simply pass a function props then it will emit by the plugin.

function App() {
    let $tawkMessenger;
    
    onMount(() => {
        $tawkMessenger.onLoad(() => {
            // place your code here
        });
    });

    return (
        <TawkMessenger
            propertyId="property_id"
            widgetId="widget_id"
            ref={$tawkMessenger}}/>
    );
}