This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-20
Channels
- # ai (4)
- # aleph (1)
- # babashka (127)
- # beginners (89)
- # calva (44)
- # cider (22)
- # clerk (74)
- # clj-commons (5)
- # clj-kondo (3)
- # cljs-dev (51)
- # clojure (117)
- # clojure-europe (22)
- # clojure-nl (2)
- # clojure-norway (100)
- # clojure-uk (2)
- # clojurescript (64)
- # data-science (26)
- # datalevin (3)
- # datascript (2)
- # emacs (10)
- # events (5)
- # figwheel-main (12)
- # helix (2)
- # honeysql (15)
- # hoplon (3)
- # jobs-discuss (32)
- # malli (3)
- # polylith (3)
- # re-frame (2)
- # reitit (15)
- # releases (2)
- # sci (14)
- # shadow-cljs (14)
- # specter (2)
- # tools-build (7)
- # xtdb (16)
help! i barely understand react and i’m trying to get a listbox working (using headlessui) what am i doing wrong
(def people [{:id 1, :name "Wade Cooper"}
{:id 2, :name "Arlene Mccoy"}
{:id 3, :name "Devon Webb"}
{:id 4, :name "Tom Cook"}
{:id 5, :name "Tanya Fox"}
{:id 6, :name "Hellen Schmidt"}])
(defnc my-listbox []
(let [[state set-state] (hooks/use-state (second people))]
(<> ($ ui/Listbox {:value state :onChange set-state
:className "border"}
($ ui/Listbox.Button {:className "text-xs text-red-500 border border-blue-500 rounded m-4 p-4 shadow-2xl"}
(:name state))
($ ui/Listbox.Options
(for [p people]
(<> ($ ui/Listbox.Option {:key (:id p) :value p
:className "ui-active:bg-blue-500"}
($ ui/CheckIcon :className "hidden ui-selected:block")
(:name p)))))))))
I’ve tried every permutation i can think off to get fragments working but i keep getting the following error
Uncaught Error: Passing props on "Fragment"!
The current component <Listbox /> is rendering a "Fragment".
However we need to passthrough the following props:
- className
- ref
You can apply a few solutions:
- Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".
- Render a single element as the child so that we can forward the props onto that element.
I think you do not need fragment <> inside Listbox.Options since Listbox.Option is enclosing CheckIcon, therefore is one element. We usually use <> or div to group elements.