LucasBassetti / react-simple-chatbot

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

How to Store Options value in the state #382

Closed salahbm closed 10 months ago

salahbm commented 10 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 10 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