react-simple-chatbot icon indicating copy to clipboard operation
react-simple-chatbot copied to clipboard

TriggerNextStep triggered step twice in the chatbot

Open zmo123 opened this issue 5 years ago • 13 comments

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

image

zmo123 avatar Jul 25 '20 15:07 zmo123

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.

rnovacek avatar Aug 26 '20 09:08 rnovacek

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.

Can you share your code ?

Furkan-Oeztuerk avatar Apr 12 '21 21:04 Furkan-Oeztuerk

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',
            ...
        },
    ]}
/>

rnovacek avatar Apr 14 '21 17:04 rnovacek

I was getting something similar, except each successive step was doubling the previous number of steps.

Turning off strict mode fixed the issue immediately.

andywalters47 avatar May 30 '22 16:05 andywalters47

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!

JAgagwuncha avatar Jun 02 '22 16:06 JAgagwuncha

Sure, just remove <React.StrictMode> and </React.StrictMode> from your code. Typically this is found in index.js.

andywalters47 avatar Jun 02 '22 16:06 andywalters47

Sure, just remove <React.StrictMode> and </React.StrictMode> from your code. Typically this is found in index.js.

Thank you greatly, this has helped me enormously!!

JAgagwuncha avatar Jun 02 '22 16:06 JAgagwuncha

Sure, just remove <React.StrictMode> and </React.StrictMode> from your code. Typically this is found in index.js.

Thanks bro..u really saved me!

KushBhasin avatar Aug 08 '22 20:08 KushBhasin

in nextjs when i am removing strictmode its not working @andywalters47

Sheetalviga avatar Aug 21 '22 14:08 Sheetalviga

Sure, just remove <React.StrictMode> and </React.StrictMode> from your code. Typically this is found in index.js.

thanks it worked

ratul47 avatar Nov 08 '22 09:11 ratul47

thanks

sheshamramu avatar Nov 25 '22 12:11 sheshamramu