admin管理员组文章数量:1355555
The cities data is coming from an Api cityOptions is being logged to the console, but when I try to show it in the UI in a dropdown, no data shows.
const cityOptions = cities?.map((city) => ({
value: city.id.toString(),
label: city.name,
})) || [];
console.log("cityoptions", cityOptions)
<Select
name="city"
placeholder="Cities"
value={city || null}
maw={200}
size="md"
data={isLoading ? []: cityOptions}
disabled={isLoading}
onChange={(value) => setCity(value as string)}
icon={<IconSelector size={18} stroke={1.75} />}
clearable
style={{ marginBottom: 0 }}
/>
The cities data is coming from an Api cityOptions is being logged to the console, but when I try to show it in the UI in a dropdown, no data shows.
const cityOptions = cities?.map((city) => ({
value: city.id.toString(),
label: city.name,
})) || [];
console.log("cityoptions", cityOptions)
<Select
name="city"
placeholder="Cities"
value={city || null}
maw={200}
size="md"
data={isLoading ? []: cityOptions}
disabled={isLoading}
onChange={(value) => setCity(value as string)}
icon={<IconSelector size={18} stroke={1.75} />}
clearable
style={{ marginBottom: 0 }}
/>
Share
Improve this question
asked Mar 30 at 6:23
AakritiAakriti
1
1
- A follow-up discussion was started:
- Please add a specific question to improve the post. So far there is no direct question. – chux Commented Apr 1 at 0:41
1 Answer
Reset to default 0As the documentation states, there is no props called icon
; there is checkIconPosition
and the property is right/left. You are using icon , which may be causing the issue. Please visit this documentation
[https://mantine.dev/core/select/?t=props]
Please update your code by following code,
const cityOptions = cities?.map((city) => ({
value: city.id.toString(),
label: city.name,
})) || [];
console.log("cityoptions", cityOptions);
console.log("isLoading:", isLoading);
return (
<Select
name="city"
placeholder="Cities"
value={city}
maw={200}
size="md"
data={cityOptions}
disabled={isLoading}
onChange={(value) => setCity(value)}
leftSection={<IconSelector size={18} stroke={1.75} />}
clearable
nothingFound="No cities found"
style={{ marginBottom: 0 }}
/>
);
};
本文标签: javascriptData not rendering in Mantine39s Select ComponentStack Overflow
版权声明:本文标题:javascript - Data not rendering in Mantine's Select Component - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743995414a2572898.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论