I am using react-chat-widget node module in my react project as a webchat, When I implemented setQuickButtons the buttons are not hiding even after button click. How can I make the buttons hidden once clicked?
In the handleQuickButtonClicked method I was setting quick buttons but those methods are staying on the screen even after clicking one of the buttons.
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Provider } from 'react-redux';
import { store } from './store';
import { Widget, addResponseMessage, addUserMessage, toggleWidget, setQuickButtons } from 'react-chat-widget';
import 'react-chat-widget/lib/styles.css';
import './index.css';
class Reactwidget extends React.Component {
constructor(props) {
super(props);
}
handleNewUserMessage(message) {
console.log(message);
if (message.includes('hi')) {
addResponseMessage('Welcome to this test chatbot')
}
}
handleQuickButtonClicked(message) {
console.log('quick button clicked ' + message)
if (message.includes('button') || message === 'button') {
addUserMessage('you clicked button ' + message);
addResponseMessage('hi')
}
}
componentDidMount() {
console.log('didmount')
addResponseMessage('hello there')
toggleWidget();
const buttonList = [{
label: 'Button1',
value: 'button1'
},
{
label: 'Button2',
value: 'button2'
},
{
label: 'Button3',
value: 'button3'
}];
setQuickButtons(buttonList)
}
render() {
return (
<div>
<Widget handleNewUserMessage={this.handleNewUserMessage}
title="Test webchat"
senderPlaceHolder="enter here"
showCloseButton={true}
showTimeStamp={true}
autofocus={true}
handleQuickButtonClicked={this.handleQuickButtonClicked}
toggleWidget={true}
/>
</div>
)
}
}
ReactDOM.render(
<React.StrictMode>
<Reactwidget />
</React.StrictMode>,
document.getElementById('root')
);
This is pretty late but, try adding
setQuickButtons([]);
, which simply "replaces" the buttons with no buttons.