Skip to content

docs: JSX Example Code of Select Causing Warning in React #3287

@jlzhjp

Description

@jlzhjp

On which page do you see this issue?

https://daisyui.com/components/select/

Describe the issue

Hi, Thank you for this great library!
In the provided jsx example code from the documentation, the <select> element uses the selected attribute directly on an <option> tag, which is not recommended in React.

<select className="select w-full max-w-xs">
  <option disabled selected>Pick your favorite Simpson</option>
  <option>Homer</option>
  <option>Marge</option>
  <option>Bart</option>
  <option>Lisa</option>
  <option>Maggie</option>
</select>

This results in the following warning:

Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.

Here's a link to the react documentation:
https://react.dev/reference/react-dom/components/select#providing-an-initially-selected-option

What browsers are you seeing the problem on?

All browsers

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions