How to get value from Shadcn "Select" component

Hey guys I'm mapping some categories and sub-categories over a shadcn select component in a form. My list of categories and subs is getting quite long so i want to use to Select components. I've tried a couple ways trying to get the main category name with useState to map its subcategory list into the second Select component but I'm struggling a bit. Has anyone done this before?
1 Reply
dollahane23033
dollahane23033OP15mo ago
Heres my current code: <Select> <SelectTrigger className="w-60"> <SelectValue {...field} /> </SelectTrigger> <SelectContent className=" max-h-60 overflow-auto p-2"> {categoryItems.map((category, index) => ( <div key={index}> <hr className="mb-2"></hr> <p className="font-bold" key={category.name}> {category.name} </p> {category.subCategories.map((subs) => ( <SelectItem key={subs} value={subs}> {subs} </SelectItem> ))} </div> ))} </SelectContent> </Select>
Want results from more Discord servers?
Add your server