primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.96k stars 1.06k forks source link

Dropdown: warning when using useOptionAsValue #7409

Open sujit-baniya opened 2 weeks ago

sujit-baniya commented 2 weeks ago

Describe the bug

Hi all, I'm using primreact/dropdown. When using useOptionAsValue I'm getting warning from React.

https://primereact.org/dropdown/#api.Dropdown.props.useOptionAsValue

<Dropdown
    value={selectedDate}
    useOptionAsValue
    options={availableDates}
    onChange={(e) => setSelectedDate(e.value)}
    placeholder="Select a DOS"
    className="date-dropdown"
/>
Warning: React does not recognize the `useOptionAsValue` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `useoptionasvalue` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
    at div
    at http://localhost:5173/node_modules/.vite/deps/chunk-MAEDPHWQ.js?v=1852453c:809:20
    at div
    at div
    at div
    at main
    at div
    at div
    at div
    at http://localhost:5173/node_modules/.vite/deps/primereact_blockui.js?v=6230d636:178:20
    at CodingBlock (http://localhost:5173/src/app/components/encounters/forms/CodingBlock.tsx?t=1731398116530:78:31)
    at CodingProvider (http://localhost:5173/src/app/hooks/Coding.tsx?t=1731398057470:125:34)

Reproducer

No response

System Information

"primereact": "latest",
        "prop-types": "^15.8.1",
        "qrcode": "^1.5.4",
        "qs": "^6.13.0",
        "react": "^18.3.1",
        "react-dom": "^18.3.1",
        "react-fast-compare": "^3.2.2",
        "react-hook-form": "^7.53.2",

Steps to reproduce the behavior

<Dropdown
    value={selectedDate}
    useOptionAsValue
    options={availableDates}
    onChange={(e) => setSelectedDate(e.value)}
    placeholder="Select a DOS"
    className="date-dropdown"
/>

Expected behavior

There should not have any warning