search

Home  >  Q&A  >  body text

My disabled state React selector doesn't show any default value

I'm new to react and I'm having a hard time figuring out why my defaultValueAttributes doesn't display anything:

<Select
    id="my_disabled_select"
    name="my_disabled_select"
    disabled
    defaultValue={connectedUser.options[0]}
/>

I tried showing connectedUser.options[0] in the InputLabel tag and the value is defined!

Does anyone know why this happens and how to fix it?

P粉464113078P粉464113078283 days ago435

reply all(1)I'll reply

  • P粉320361201

    P粉3203612012024-02-18 15:18:53

    You are missing the corresponding MenuItem child component so Select knows what to render.

    Something like this should work:

    See this ExampleStack Blitz

    reply
    0
  • Cancelreply