Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages duplicate #346

Open
Esshahn opened this issue Jun 28, 2022 · 16 comments
Open

Messages duplicate #346

Esshahn opened this issue Jun 28, 2022 · 16 comments

Comments

@Esshahn
Copy link

Esshahn commented Jun 28, 2022

Describe the bug
Messages are doubled with each new trigger.

To Reproduce
Steps to reproduce the behavior:

  1. clean install the repo inside a fresh react app.
  2. 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

Bildschirmfoto 2022-06-28 um 15 51 27

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;
@krownsh
Copy link

krownsh commented Jul 7, 2022

I got the same problem...

@Esshahn
Copy link
Author

Esshahn commented Jul 7, 2022

I found out that it's related with create react app, but I don't know why. I switched to Vite and it worked then.

@Esshahn
Copy link
Author

Esshahn commented Jul 7, 2022

I've investigated more an found the difference that made it work for me.
Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

@Darpan-favfly
Copy link

Platform: - Next.js
File:- next.config.js

#Issue Solve...
Solution:- Change reactStrictMode value TRUE to FALSE

======= Code =======

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  swcMinify: true,
};

module.exports = nextConfig;

@ScreamZ
Copy link

ScreamZ commented Oct 31, 2022

With react 18 strict mode enable useEffect to run twice in development, that's why this library might be bugged

@Eduardo-Miguel
Copy link

Eduardo-Miguel commented Nov 26, 2022

I've investigated more an found the difference that made it work for me. Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

This worked for me thanks!!!

@hamid-yg
Copy link

I've investigated more an found the difference that made it work for me. Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

This works for me as well. Thanks

@IbrahimLakhzine
Copy link

I've investigated more an found the difference that made it work for me. Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

this worked for me too thanks for the help.

@Birtija
Copy link

Birtija commented Mar 28, 2023

I've investigated more an found the difference that made it work for me. Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

This did it for me!

@sajid1545
Copy link

I've investigated more an found the difference that made it work for me. Before I used:

import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

which produced the error, switching it to

import { render } from "react-dom";
render(<App />, document.getElementById("root"));

made it work. Hope that helps.

It worked for me too

@SaleemMalik632
Copy link

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
},
]

@bharghu
Copy link

bharghu commented Jan 17, 2024

Platform: - Next.js File:- next.config.js

#Issue Solve... Solution:- Change reactStrictMode value TRUE to FALSE

======= Code =======

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  swcMinify: true,
};

module.exports = nextConfig;

yes its work fine, thanks to resolve this doubling issue - see the example of implementation - https://shitalacademy.com

@EliusCaleb
Copy link

Platform: - Next.js File:- next.config.js
#Issue Solve... Solution:- Change reactStrictMode value TRUE to FALSE
======= Code =======

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  swcMinifs y: true,
};

module.exports = nextConfig;

yes its work fine, thanks to resolve this doubling issue - see the example of implementation - https://shitalacademy.com

how to you style this component

@bharghu
Copy link

bharghu commented Jan 23, 2024

Platform: - Next.js File:- next.config.js
#Issue Solve... Solution:- Change reactStrictMode value TRUE to FALSE
======= Code =======

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  swcMinifs y: true,
};

module.exports = nextConfig;

yes its work fine, thanks to resolve this doubling issue - see the example of implementation - https://shitalacademy.com

how to you style this component

define -> const theme in top and use theme in "themeprovider"

@EliusCaleb
Copy link

Thanks Noted

@thachsteven
Copy link

Platform: - Next.js File:- next.config.js

#Issue Solve... Solution:- Change reactStrictMode value TRUE to FALSE

======= Code =======

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  swcMinify: true,
};

module.exports = nextConfig;

Thanks for your helping !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests