reagent

DeepReef11 2023-06-06T17:31:05.195809Z

I'm a begginner in cljs and I'm trying to use reagent in logseq plugin. A Logseq block can read html. I've tried sending a simple component:

(defn simple-component []
  [:div
   [:p "I am a component!"]
   [:p.someclass
    "I have " [:strong "bold"]
    [:span {:style {:color "red"}} " and red "] "text."]])
into a logseq block, but that appears as [object object]. So I suppose I should have something that manage the react component and then update the logseq block with the html rendered by the component. How to do that? (I've already asked on Logseq Discord)

Sam Ritchie 2023-06-12T03:06:42.173459Z

So did you get logseq to render a reagent component?

p-himik 2023-06-06T17:43:03.887109Z

How exactly do you embed that component in a block?

p-himik 2023-06-06T17:46:05.115849Z

And yeah, it's most definitely a question for Logseq. Your CLJS code looks just fine. The reason for [object Object] is probably because it doesn't recognize whatever you're actually embedding as Reagent Hiccup. But the code itself is correct, there's nothing wrong with it.

DeepReef11 2023-06-06T17:55:25.215019Z

Do I need to have a :require in my .cljs for reagent? I haven't seen any in examples

DeepReef11 2023-06-06T17:56:20.219819Z

(-> (js/logseq.Editor.updateBlock block-uuid (simple-component))

DeepReef11 2023-06-06T17:58:37.934629Z

I don't get any error when I run this, so I suppose it's working? I've also added the reacts deps in shadow-cljs.edn

p-himik 2023-06-06T18:03:36.927839Z

I have zero clue. While I use Logseq myself, the only Hiccup-related thing that I do is embedding static Hiccup directly into blocks.

p-himik 2023-06-06T18:04:12.060809Z

If the Logseq documentation is lacking in this regard, perhaps you can check out the sources of one of the many plugins it has.

DeepReef11 2023-06-06T21:13:31.349649Z

There's a react typescript playground plugin, but I don't really understand where this is rendered

p-himik 2023-06-06T21:17:59.328829Z

https://github.com/tiensonqin/logseq-cljs-playground

DeepReef11 2023-06-06T23:37:43.426699Z

edit: Solved the following with npm i react react-dom The documentation here should be changed to mention to also install npm packages, not or install. https://github.com/reagent-project/reagent I have the same problem as this user. The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs". I do have reagent, react and react dom in shadow deps. I'.ve ran yarn. What else do I need? https://clojureverse.org/t/the-required-namespace-react-dom-is-not-available-it-was-required-by-reagent-dom-cljs/8536