react-chat-widget
react-chat-widget copied to clipboard
badge doesn't increment
I used the react-chat-widget to create a chatbot.
When the bot replies to the user I want to increment the badge's value. I created a global var that increments when the bot answers and get back to zero when the user write his input. the I pass it to the badge as the following
render() { return (<Widget badge={} handleNewUserMessage={this.handleNewUserMessage} profileAvatar={profileAvatar} subtitle="" title="Chatbot" /> );
but it seems not be working.
So I am wondering how it does work and how can I resolve my issue
You need to pass number in badge for example
badge='4'
here your working code
render() { return (<Widget badge=4 handleNewUserMessage={this.handleNewUserMessage} profileAvatar={profileAvatar} subtitle="" title="Chatbot" /> );
You need to count the messages on the addResponseMessage that updates your badge. Maybe push the messages into an array and get the length of the array and use that to update the badge.
Can someone suggest a more clear approach towards this
the standart addResponseMessage
method set a number to badge count, when widget is in minimized state.
but, when use the renderCustomComponent
method does not set a number for the badge count.
I agree with @kartikmaan. This could use a more clear way to be done. Either exposing the current count so we can pass a new value to increment it, or a method to increment the value by a given number. Here is a way to get it working in the meantime:
This worked, but it just seems very hacky if its already being kept track of.