Fork me on GitHub
#hyperfiddle
<
2024-03-30
>
Absolute Negativity15:03:18

Can I make e/server ignores unserializable value and pass it to the outer e/client?

(e/client
    (uix/$ antd/Dropdown
      {:menu {:items
              (e/server
                (e/for-by :entity/id
                    [entitiy (e/server (find-entities state/db))]
                  (e/client
                    {:label (uix/$ :div (e/server (:entity/id entity)))
                     :key   id})))}}))
Here e/server would complain about the React component in item's labels. I'd like to have the full db entity in server context when constructing the React component.

Vincent05:03:06

is the nested e/server intentional

henrik07:04:40

You need move the for-by to the client and fetch each entity individually within the for-by. Alternatively, build up a complete payload server-side, then loop over it on the client. In Electric, the mounting of DOM elements is a side effect produced by calling the dom/xyz constructors, which is why this would work if it were pure Electric code. In the case of UIx, it wants the return value of the for-by , and produces no side-effects. Hence the return value of the for-by becomes important, and how it passes between client and server matters.

❤️ 1