79173889

Date: 2024-11-09 23:37:46
Score: 1
Natty:
Report link

Your problem is the key, just use the intended value as the key in this example the category is the value so use it as the key.

"use client";

import React, { useState } from "react";
import { Select, SelectSection, SelectItem } from "@nextui-org/select";
const ServiceInfoContainer: React.FC = () => {
  const [service, setService] = useState<string>("");

  const categories: string[] = [
    "Beginner (0-1 year)",
    "Intermediate (2-3 years)",
    "Experienced (4-5 years)",
    "Expert (6+ years)",
  ];

  const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
    setService(e.target.value);
  };

  return (
    <>
      Service: {service}
      <Select onChange={handleChange} label="Select years of experience">
        {categories.map((categ) => (
          <SelectItem key={categ} value={categ}>
            {categ}
          </SelectItem>
        ))}
      </Select>
    </>
  );
};

export default ServiceInfoContainer;

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: David Adokuru