Repository navigation
Closed
Labels
component: selectChanges related to the select component.
Description
Bug report
Current behavior
When I want to use array of object as items for select and pass some item to defaultValue or to value, I get this error. This happens because each object has icon, icon is some react component. And it unable to be serialized in this hook (from stack trace):
base-ui/packages/utils/src/useControlled.ts
Lines 56 to 66 in 1e0f08c
| React.useEffect(() => { | |
| // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is for more details. | |
| if (!isControlled && JSON.stringify(defaultValue) !== JSON.stringify(defaultProp)) { | |
| console.error( | |
| [ | |
| `Base UI: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` + | |
| `To suppress this warning opt to use a controlled ${name}.`, | |
| ].join('\n'), | |
| ); | |
| } | |
| }, [JSON.stringify(defaultProp)]); |
There is an example:
// usage
<Select.Root items={shippingMethods} defaultValue={shippingMethods[0]}>// data
import { AiFillAlipaySquare, AiFillBehanceSquare, AiFillFilter } from "react-icons/ai";
const shippingMethods: ShippingMethod[] = [
{
value: "standard",
label: "Standard",
duration: "Delivers in 4-6 business days",
price: "$4.99",
icon: <AiFillAlipaySquare />,
},
{
value: "express",
label: "Express",
duration: "Delivers in 2-3 business days",
price: "$9.99",
icon: <AiFillBehanceSquare />,
},
{
value: "overnight",
label: "Overnight",
duration: "Delivers next business day",
price: "$19.99",
icon: <AiFillFilter />,
},
];Expected behavior
No errors
Reproducible example
Base UI version
@base-ui/[email protected]
Which browser are you using?
Chrome latest
Which OS are you using?
Windows 11
Metadata
Metadata
Assignees
Labels
component: selectChanges related to the select component.
Activity
Profesor08 commentedon Mar 26, 2026
I think, using
Object.is()or es-toolkit/isEqual should fix this issue.github-actions commentedon Apr 7, 2026
This fix will be available in the next npm release of Base UI.
In the meantime, you can try it out on our Canary release channel: