Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jlzhjp opened this issue Nov 22, 2024 · 1 comment
Open

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

jlzhjp opened this issue Nov 22, 2024 · 1 comment

Comments

@jlzhjp
Copy link

jlzhjp commented Nov 22, 2024

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

Copy link

Thank you @jlzhjp for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant