Is it possible to display existing records as tags using the useSelect(), #1651
Answered
by
omeraplak
BenGardiner123
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
omeraplak
Mar 21, 2022
Replies: 1 comment
-
Hey @BenGardiner123 , I created a CodeSandbox for you, https://codesandbox.io/s/refine-use-select-example-forked-s55ne?file=/src/pages/posts/create.tsx const {
selectProps,
queryResult,
defaultValueQueryResult
} = useSelect();
const allOptions = [
...(queryResult.data?.data || []),
...(defaultValueQueryResult.data?.data || [])
];
<Select
{...categorySelectProps}
options={allOptions.map((p) => ({
label: `${p.title}-${p.id}`,
value: p.id
}))}
/> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
omeraplak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @BenGardiner123 ,
Thank you for contacting us! The easiest way to do this is to use the
queryResult
returned from theuseSelect
hook.I created a CodeSandbox for you, https://codesandbox.io/s/refine-use-select-example-forked-s55ne?file=/src/pages/posts/create.tsx