This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-04
Channels
- # aleph (8)
- # aws (14)
- # babashka (37)
- # beginners (30)
- # calva (5)
- # cider (4)
- # clj-kondo (21)
- # cljsrn (4)
- # clojure (234)
- # clojure-denmark (1)
- # clojure-europe (10)
- # clojure-france (10)
- # clojure-italy (4)
- # clojure-nl (17)
- # clojure-sanfrancisco (1)
- # clojure-spec (8)
- # clojure-uk (44)
- # clojurescript (20)
- # cursive (9)
- # datascript (2)
- # datomic (5)
- # emacs (9)
- # fulcro (50)
- # graalvm (32)
- # jackdaw (18)
- # leiningen (1)
- # malli (10)
- # meander (10)
- # nrepl (10)
- # off-topic (15)
- # pathom (20)
- # re-frame (14)
- # reagent (37)
- # reitit (7)
- # ring (1)
- # shadow-cljs (102)
- # test-check (6)
- # tree-sitter (15)
- # vim (4)
- # xtdb (2)
- # yada (1)
and start the “hooks” build, then navigate to: http://localhost:9001/hooks.html
This is a working demo that creates Fulcro components that can use hooks, WITHOUT integration into the defsc macro…that’s the work that remains.
The macro is going to need to detect the :use-hooks?
option, and just generate the code differently.
https://github.com/fulcrologic/fulcro/pull/378/files#diff-af3a2210946f382213242b513d5c15b3R26
is the primary comment to read. The demo creates a Hook component. The :render
option is just a plain function, and inside of that function you can use normal react hooks stuff.
The current macro is able to error check and morph the options map; however, it builds render for classes, so that’ll need to change…that’s most of the work
I’m trying out https://github.com/fulcrologic/fulcro-garden-css. What’s the proper way to include CSS from a utility component (that doesn’t have an ident or query of its own)? I.e.:
(defsc B [this _props comp-props]
{:css [[:.b {…}]]}
(div :.b …))
(def ui-b …)
(defsc A [this {:a/keys [id …]}]
{:query [:a/id
…]
:ident :a/id
:css [[:.a {…}]]}
(div :.a
(ui-b (comp/computed {…}))))
(def ui-a …)
Some docstrings reference :include-children
, but it must have been refactored to :css-include
at some point:
(defn get-includes
"Returns the list of components from the include-children method of a component"
[component]
(let [includes (some-> component comp/component-options :css-include)]
(if (fn? includes)
(includes)
(or includes []))))
Fulcro 3.1.17-SNAPSHOT has the experimental hooks support. Just add :use-hooks? true
to the component options (and do NOT use component lifecycles…no error checking yet to tell you when you screw that up, it just won’t work)
I'm trying to use https://github.com/metabase/toucan in a Fulcro project. It gives me an error like this:
The required namespace "toucan.db" is not available, it was required by "sheluchin/client.cljs".
"toucan/db.clj" was found on the classpath. Should this be a .cljs file?
How do I make use of that?@alex.sheluchin this is a #shadow-cljs thing, shadow doesn't use cljsjs
, so you have to pull JS dependencies using node/npm
@wilkerlucio I don't understand. Toucan is a CLJ library. What JS dependencies are you referring to? The issue I'm having is that I'm trying to make use of Toucan, a CLJ library, inside of client.cljs
. I don't understand the fullstack model of Fulcro yet, but I think it's possible to use CLJ stuff in a project.
Ultimately, I just want to make some calls to a 3rd party REST API, save the results into a Postgres DB, and display the stored data on the frontend.
@alex.sheluchin humm, I'm was guessing that the library required that, but seems "sheluchin/client.cljs"
is the culprid of trying to require something that's, sorry, my confusion, now I'm guessing you are trying ot require something thatls clj
on a cljc
file
if that's the case, you need to use some reader conditionals to only do those parts in clj
land
No worries, appreciate the help anyhow. I'm not familiar with how reader conditionals work, going to give https://clojure.org/guides/reader_conditionals a good look.
oh, I see its a cljs
file, so, you can't require clj
things on cljs
file
they are different environments (JVM vs JS)
By default Fulcro is running in the JVM and doing server-side DOM rendering, right?
I'm not sure on the template, I would guess SSR is not enabled by default, but someone else may have a more accurate response
you need to be aware about what code is running where, because that dictates what you can use (for example, seems like you can't use toucan
on the CLJS side)
Yes, that part is a little unclear to me. My thinking is that I need to set up the server (as detailed here http://book.fulcrologic.com/#_setting_up_a_server) and use toucan in that code, and then query it from the CLJS side of things. Does that sound about right?
If you want the data to be dynamic during runtime, then yes you would need to make a server-side resolver for your query and then query that from the client across the wire. If it’s enough to run it once during compilation of the client, then you could just inline the result into the CLJS code
I suggest you check the video series, it covers all of this we are discussing https://www.youtube.com/playlist?list=PLVi9lDx-4C_T7jkihlQflyqGqU4xVtsfi
(defsc TextObject [_this {:text-object/keys [text editable]}]
{:query [:text-object/id :text-object/text :text-object/editable]
:ident :text-object/id }
(if editable
(str "EDIT: " text)
(dom/p {:onClick #(js/alert "foo")}
(str text))))
I've got such component. :text-object/{id,text}
are provided by remote. However, I'd like :text-object/editable
to be UI-only.
But it obviously have value :text-object/editable :com.wsscode.pathom.core/not-found
How should I deal with case like that? It seems invalid to add editable
to "backend" while it's UI-local state only.
@slawek098 for UI only values you can use keywords with the :ui
namespace, example: :ui/editable
or :ui.text-object/editable
Unless I'm mistaken :ui.text-object/editable
will not work by default.
@slawek098 - the default logic is here: https://github.com/fulcrologic/fulcro/blob/c69d475996fe1341b24a330af045f3cb0fe6696d/src/main/com/fulcrologic/fulcro/application.cljc#L192-L217
You can also customize it, by passing in your own :global-eql-transform
function to application/fulcro-app
: https://github.com/fulcrologic/fulcro/blob/c69d475996fe1341b24a330af045f3cb0fe6696d/src/main/com/fulcrologic/fulcro/application.cljc#L237-L238
those are automatically removed from when there is integration with the network layer