Reputation: 6259
I have the following component:
Somehow DropdownMultiselect
does not update, even though the variables changed.
What do I wrong here?
function Sidebar({chartOptions}) {
let variables = []
if(chartOptions){
variables = chartOptions
}
return (
<DropdownMultiselect options={variables} name="variables"/>
)
}
Upvotes: 0
Views: 43
Reputation: 1159
You cannot mutate variable like that in React. You can use the prop directly, using ??
to handle the case where chartOptions is null or undefined :
function Sidebar({chartOptions}) {
return (
<DropdownMultiselect options={chartOptions ?? []} name="variables"/>
)
}
Upvotes: 1