helix

https://github.com/Lokeh/helix
Lucy Wang 2021-05-19T01:22:38.004Z

@dominicm in cljs you can always delegate the body of the method to a function, and when this functions is re-evaluated it would also take effect in the class. Not sure if I get you want.

dominicm 2021-05-19T15:06:20.012500Z

Sure 馃檪 Clojure does this automatically under the hood for you with gen-class, to allow you to do this without doing it manually!

dominicm 2021-05-19T15:06:34.012700Z

It would be cool if the new shadow classes also did that.

位mmij 2021-05-19T09:12:15.004500Z

Hi everyone.

位mmij 2021-05-19T09:14:13.005900Z

How can i refer defnc in helix.core namespace when it is not define? (ns my-app.core
  (:require [helix.core :refer [defnc $]]
            [helix.hooks :as hooks]
            [helix.dom :as d]
            ["react-dom" :as rdom]))

Aron 2021-05-19T09:16:56.006100Z

lgtm

Aron 2021-05-19T10:03:07.006600Z

but I am not sure I get your full meaning, what is 'not define'?

位mmij 2021-05-19T10:40:56.007200Z

i cant use the defnc. 

位mmij 2021-05-19T10:41:16.007400Z

(defnc greeting
  "A component which greets a user."
  [{:keys [name]}]
  ;; use helix.dom to create DOM elements
  (d/div "Hello, " (d/strong name) "!"))

(defnc app []
  (let [[state set-state] (hooks/use-state {:name "Helix User"})]
    (d/div
     (d/h1 "Welcome!")
     ;; create elements out of components
     ($ greetings {:name (:name state)})
     (d/input {:value (:name state)
               :on-change #(set-state assoc :name (.. % -target -value))}))))

位mmij 2021-05-19T10:41:58.008Z

It was refer from the helix.core namespace but defnc doesnt exist there.

位mmij 2021-05-19T10:45:55.008100Z

位mmij 2021-05-19T10:52:44.010700Z

I can use the $ but not defnc in (:require [helix.core :refer [defnc $]]). I look at the helix.core.clj and search the entire namespace but I cant seem to find defnc anywhere.

jimmy 2021-05-20T12:19:32.014500Z

Not a bother at all. Editors are not always great at analyzing code. Sometimes you have to tell them more information. Sometimes they just aren't super smart. Generally I'd just advise to not worth so much about what the editor understands. Worry about the running program itself :)

jimmy 2021-05-19T12:13:12.011100Z

What is the actual error you get when you try to run your program? I see the screenshot of your editor giving red squiggles. That could be an editor issue. Does it actually throw errors when you run the program?

Aron 2021-05-19T13:00:41.011700Z

Can I use defhook to define a multi arity hook? Like this https://stuartsierra.com/2015/06/01/clojure-donts-optional-arguments-with-varargs ?

位mmij 2021-05-19T13:10:12.011900Z

I seems that I just fix itself after I restart build. I doesn't throw an error only warning.

位mmij 2021-05-19T13:10:26.012100Z

I made to work now thanks.

位mmij 2021-05-19T14:26:55.012300Z

It still confuses me though. Why I am getting the helix.core.cljs instead of helix.core.clj? That is why when I control click the helix.core it take me to the cljs file which doesn't contain the defmacro defnc because it was implemented in helix.core.clj

jimmy 2021-05-19T15:21:58.012900Z

What editor are you using? That is the behavior of your editor.

lilactown 2021-05-19T16:49:38.013200Z

I think it does work but only accidentally

lilactown 2021-05-19T16:50:56.013300Z

I'm with jimmy; it sounds like you're talking about how your editor behaves with helix and defnc, not how your app is building and behaving?

lilactown 2021-05-19T16:51:33.013500Z

it looks like you're using VS Code, which I know defaults to using clj-kondo as its linter. clj-kondo does not understand defnc by default

Aron 2021-05-19T17:01:22.013800Z

: D

Aron 2021-05-19T17:01:29.014Z

sounds promising

位mmij 2021-05-19T23:58:20.014100Z

Im using vscode. But the program works though. I got the display on localhost correctly. Sorry for bothering. I am just programming for fun.