react-chat-widget icon indicating copy to clipboard operation
react-chat-widget copied to clipboard

How does customLauncher works?

Open jiaqihuangrerere opened this issue 6 years ago • 9 comments

Hello, if i have a component function, and I pass it the Widget like this

Welcome(props) { return

Hello Yeah

; } <Widget ... customLauncher = {this.Welcome} />

It is not displaying Hello Yeah, so how do you use this function?

jiaqihuangrerere avatar Jul 27 '18 16:07 jiaqihuangrerere

Hi @jiaqihuangrerere thanks for asking! This new prop can be used as the following:

import Launcher from '@components/Launcher';

...

class App extends React.Component {

  getCustomLauncher = handleToggle => (
    // The return will be your own Launcher component
      <Launcher
        handleToggle={toggle}
        ...
      />
   );

  ...

  render() {
    return (
       <Widget
         customLauncher={handleToggle => this.getCustomLauncher(handleToggle)}
       />
    );
  }
}

Hope this helps! 😄

mcallegari10 avatar Jul 27 '18 20:07 mcallegari10

<Launcher handleToggle={toggle} ... />

What does toggle refer to? Are you referring to this page? https://github.com/Wolox/react-chat-widget/blob/master/src/components/Widget/components/Launcher/index.js

jiaqihuangrerere avatar Jul 27 '18 21:07 jiaqihuangrerere

That handleToggle is our function to toggle the Widget (you can see it in here). You can use it to toggle the widget as much as you need 😄

mcallegari10 avatar Jul 30 '18 20:07 mcallegari10

I am struggling with this. I am trying to change the Launcher image picture. I see you pass {toggle} as a prop to Launcher. Are we defining this callback function to return a bool?

mrwadepro avatar Sep 18 '18 03:09 mrwadepro

@mcallegari10 First of all, thanks for your commitment collaborating in this project! Can you please shed some light how to properly use the custom launcher?

I am trying to build a simple modal, i.e. neither full-screen nor a small window for a chatbot. I'll post my code as soon as I got something useful… looking towards your feedback in the meanwhile!

tafaust avatar Oct 22 '18 21:10 tafaust

I am struggling with this. I am trying to change the Launcher image picture. I see you pass {toggle} as a prop to Launcher. Are we defining this callback function to return a bool? getCustomLauncher = handleToggle => ( <button onClick={handleToggle}>Chat Now</button> ) <Widget launcher={handleToggle => this.getCustomLauncher(handleToggle)} /> I tried this way and it works !

oliviatian27 avatar Nov 13 '18 15:11 oliviatian27

@jiaqihuangrerere if you want to use an Image as a launcher you can do something like:

  launcher={handleToggle => (
    <button onClick={handleToggle}><img src={yourImage} /></button>
  )}

pabloferro avatar Nov 15 '18 14:11 pabloferro

Hello! Thanks for this awesome component! Have a question, is it possible to not have a launcher an simply have a big chat window taking the whole screen? Cheers,

salimbene avatar Mar 21 '19 13:03 salimbene

How can I get onClick event of the widget, I want to use the default button

EdmarPereira avatar May 28 '20 17:05 EdmarPereira