79663488

Date: 2025-06-12 12:00:37
Score: 0.5
Natty:
Report link

Primereact gives for that an other Component, the Dropdown component.

Read the Documentation: https://primereact.org/dropdown/ .

-----------------------------------------------------------------------------

if you want to select multiple items in MultiSelect but as default just one item selected, do this:

you should add the just the Value, which is in your options objectsarray.

// for Javascript
   
 const [selected, setSelected] = useState(["Grapes"]);

// for Typescript

    type Option = {label: string, value: string}
    const [selected, setSelected] = useState<Option[], string[]>(["Grapes"]);

For more selected items as default, you should just add a new string in the Array of the useState().

All added strings should be available in your Options Objectsarray!

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Filler text (0.5): -----------------------------------------------------------------------------
  • Low reputation (1):
Posted by: Hasan Kahya