LucasBassetti / react-simple-chatbot

:speech_balloon: Easy way to create conversation chats
https://lucasbassetti.com.br/react-simple-chatbot/
MIT License
1.73k stars 598 forks source link

How to Store Options value in the state #382

Closed salahbm closed 8 months ago

salahbm commented 8 months ago

I want to store the options' selected value in state but none of the methods are helping : (

    {
      id: '9',
      options: [
        {
          value: 'social_media',
          label: 'Social Media Marketing',
          trigger: '10',
        },
        {
          value: 'seo',
          label: 'Search Engine Optimization (SEO)',
          trigger: '11',
        },
        {
          value: 'email_marketing',
          label: 'Email Marketing',
          trigger: '12',
        },
        {
          value: 'content_marketing',
          label: 'Content Marketing',
          trigger: '13',
        },
      ],
      user: true,
      validator: (value: string) => {
        const result = storeOptions(value); // stores the value in the state if stored returns true
        return result;
      },
    },
salahbm commented 8 months ago
 function handleEnd(steps: any, values: any) {
    console.log(steps);
    console.log(values);
  }
  <ChatBot
        steps={steps}
        handleEnd={(steps: any, values: any) => handleEnd(steps, values)}  />
  I found out the answer, in case someone needs there is code