LucasBassetti/react-simple-chatbot

How to Store Options value in the state

Closed this issue · 1 comments

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

 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