Skip to content

How do you get the values from the select element? #97

Answered by csandman
raulgonzalezdev asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for your feedback! For the basics of how to use this component, you should check out the docs for the original react-select component: https://react-select.com/home

But I can also give you a simple example of how to do so, you just need to use the value and onChange props to manually keep track of the value using state:

import { useState } from "react";
import { Select } from "chakra-react-select";

export const flavors = [
  { value: "vanilla", label: "Vanilla" },
  { value: "chocolate", label: "Chocolate" },
  { value: "strawberry", label: "Strawberry" },
  { value: "salted-caramel", label: "Salted Caramel" }
];

const Example = () => {
  const [selectedOptions, setSelectedOptions] 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by csandman
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #54 on May 05, 2022 19:16.