You can find the below example to see my issue: codesandox example
If I set the name property of the object, it works fine. But it is not working in other example in my application:
setRegion(item.name);
Application example:
My usestate looks like this:
const [department, setDepartment] = useState("");
Here is my application example:
<div className="sui-search-box">
<div className="department">
<label>
Department:
<Select id="depart" value={department} onChange={selectedValue =>
{
setDepartment(selectedValue.value);
setFilter("department", selectedValue.value, "any")
}}
options = {
results.map((depart, index) => {
return {
label: depart.name,
value:depart.name,
key:index
}
})
}
/>
{department}
</label>
</div>
</div>
what is the right approach to set the state and why my current sandbox is not binding properly ?