react-simple-chatbot: Messages duplicate
Describe the bug Messages are doubled with each new trigger.
To Reproduce Steps to reproduce the behavior:
- clean install the repo inside a fresh react app.
- use the code example below.
Expected behavior messages should appear only once, as defined in the code. Instead, they appear multiple times (see screenshot)
Desktop (please complete the following information):
- OS: Mac OS Monterey
- Browser Latest Chrome, Safari
Code
import "./App.css";
import ChatBot from "react-simple-chatbot";
function App() {
const steps = [
{
id: "0",
message: "Message 0",
trigger: "1",
},
{
id: "1",
message: "Message 1",
trigger: "2",
},
{
id: "2",
message: "Message 2",
end: true,
},
];
return (
<div className="App">
<ChatBot steps={steps} />
</div>
);
}
export default App;
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16
I’ve investigated more an found the difference that made it work for me. Before I used:
which produced the error, switching it to
made it work. Hope that helps.
Platform: - Next.js File:- next.config.js
#Issue Solve… Solution:- Change reactStrictMode value TRUE to FALSE
======= Code =======
It worked for me too
i got the same issue [ { id: ‘1’, message: ‘Welcome to InfoPRO’, trigger: ‘2’ }, { id: ‘2’, message: ‘Hi! Guest. Thanks for your interest. In case we get disconnected, Please provide your email address formore’, trigger: ‘Checkemail’ }, { id: ‘Checkemail’, user: true, validator: (value) => { if (!value.match(/^[\w-]+(.[\w-]+)*@([\w-]+.)+[a-zA-Z]{2,7}$/)) { return ‘Please provide a valid email address.’; } return true; }, trigger: ‘mailthanks’, }, { id: ‘mailthanks’, message: 'Thanks! ', trigger: ‘option’, }, { id: ‘option’, message: ‘Choose the Options’, end: true }, ]
This worked for me thanks!!!
With react 18 strict mode enable useEffect to run twice in development, that’s why this library might be bugged