react-simple-chatbot
react-simple-chatbot copied to clipboard
TriggerNextStep triggered step twice in the chatbot
Hi, just a quick question regarding the TriggerNextStep function used by a custom component. I am calling triggerNextStep in the constructor for my custom component to trigger the step I specified. However, even though the trigger is successful, the next step is triggered twice instead of once, I can't find a solution for that.
Below is my snippet of code, i tried called triggerNextStep in the constructor, componentWillMount, or componentDidMount, and i am getting the same behavior.
export default class MapController extends Component { constructor(props) { super(props); this.state = { level: this.props.previousStep.value, }; this.props.triggerNextStep({ value: "next", trigger: 7 }); }
Please help me address this issue! Thanks

I had the same issue, manage to work it around by removing trigger from the step definition and instead called triggerNextStep({ trigger: 'NEXT_STEP' }); from the custom component.
I had the same issue, manage to work it around by removing
triggerfrom the step definition and instead calledtriggerNextStep({ trigger: 'NEXT_STEP' });from the custom component.
Can you share your code ?
Something like this:
const CustomStep = ({ triggerNextStep }) => {
return (
<button onClick={() => triggerNextStep({ trigger: '2' })}>Next</button>
);
};
<ChatBot
steps={[
{
id: '1',
component: <CustomStep />,
asMessage: true,
// trigger: '2', <-- commented out
},
{
id: '2',
...
},
]}
/>
I was getting something similar, except each successive step was doubling the previous number of steps.
Turning off strict mode fixed the issue immediately.
I was getting something similar, except each successive step was doubling the previous number of steps.
Turning off strict mode fixed the issue immediately.
Hello, can you please let me know how to do this? As I believe I have the exact same issue!
Sure, just remove <React.StrictMode> and </React.StrictMode> from your code. Typically this is found in index.js.
Sure, just remove
<React.StrictMode>and</React.StrictMode>from your code. Typically this is found inindex.js.
Thank you greatly, this has helped me enormously!!
Sure, just remove
<React.StrictMode>and</React.StrictMode>from your code. Typically this is found inindex.js.
Thanks bro..u really saved me!
in nextjs when i am removing strictmode its not working @andywalters47
Sure, just remove
<React.StrictMode>and</React.StrictMode>from your code. Typically this is found inindex.js.
thanks it worked
thanks